如何在Deepin Linux下安装Docker容器经验分享

1.我们都知道的Docker:https://download.docker.com/

Index of /


linux/                                     2017-05-05 16:20  -
mac/                                       2017-06-08 16:20  -
win/                                       2017-06-08 16:20  -

1.1当然选择Linux啦~那么问题来了:

Index of linux/


../
centos/
debian/
fedora/
raspbian/
static/
ubuntu/

1.2选哪个?(百度一下,Deepin是基于Debian的,所以选Debian)

打开链接:https://docs.docker.com/install/linux/docker-ce/debian/

Get Docker CE for Debian

Estimated reading time: 10 minutes

To get started with Docker CE on Debian, make sure you meet the prerequisites, then install Docker.

Prerequisites

Docker EE customers

Docker EE is not supported on Debian. For a list of supported operating systems and distributions for different Docker editions, seeDocker variants.

OS requirements

To install Docker CE, you need the 64-bit version of one of these Debian or Raspbian versions:

  • Buster 10
  • Stretch 9 (stable) / Raspbian Stretch

Docker CE is supported on x86_64 (or amd64), armhf, and arm64 architectures.

Uninstall old versions

Older versions of Docker were called dockerdocker.io , or docker-engine. If these are installed, uninstall them:

$ sudo apt-get remove docker docker-engine docker.io containerd runc

It’s OK if apt-get reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved. The Docker CE package is now called docker-ce.

Install Docker CE

You can install Docker CE in different ways, depending on your needs:

  • Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach, except for Raspbian.

  • Some users download the DEB package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.

  • In testing and development environments, some users choose to use automated convenience scripts to install Docker. This is currently the only approach for Raspbian.

Install using the repository

Before you install Docker CE for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

Raspbian users cannot use this method!

For Raspbian, installing using the repository is not yet supported. You must instead use the convenience script.

SET UP THE REPOSITORY

  1. Update the apt package index:

    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:

    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg2 \
        software-properties-common
    
  3. Add Docker’s official GPG key:

    $ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
    

    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    $ sudo apt-key fingerprint 0EBFCD88
    
    pub   4096R/0EBFCD88 2017-02-22
          Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid                  Docker Release (CE deb) 
    sub   4096R/F273FCD8 2017-02-22
    
  4. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.

    Note: The lsb_release -cs sub-command below returns the name of your Debian distribution, such as stretch.

    • x86_64 / amd64
    • armhf
    • arm64
    $ sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/debian \
       $(lsb_release -cs) \
       stable"
    

     

INSTALL DOCKER CE

Note: This procedure works for Debian on x86_64 / amd64, Debian ARM, or Raspbian.

  1. Update the apt package index.

    $ sudo apt-get update
    
  2. Install the latest version of Docker CE, or go to the next step to install a specific version:

    $ sudo apt-get install docker-ce
    

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installing or updating without specifying a version in the apt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs.

  3. To install a specific version of Docker CE, list the available versions in the repo, then select and install:

    a. List the versions available in your repo:

    $ apt-cache madison docker-ce
    
      docker-ce | 5:18.09.1~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docker-ce | 5:18.09.0~3-0~debian-stretch | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docker-ce | 18.06.1~ce~3-0~debian        | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      docker-ce | 18.06.0~ce~3-0~debian        | https://download.docker.com/linux/debian stretch/stable amd64 Packages
      ...
    

    b. Install a specific version using the version string from the second column, for example, 5:18.09.1~3-0~debian-stretch .

    $ sudo apt-get install docker-ce=
    
  4. Verify that Docker CE is installed correctly by running the hello-world image.

    $ sudo docker run hello-world
    

    This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

Docker CE is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.

UPGRADE DOCKER CE

To upgrade Docker CE, first run sudo apt-get update, then follow the installation instructions, choosing the new version you want to install.

Install from a package

If you cannot use Docker’s repository to install Docker CE, you can download the .deb file for your release and install it manually. You need to download a new file each time you want to upgrade Docker.

  1. Go to https://download.docker.com/linux/debian/dists/, choose your Debian version, browse to pool/stable/, choose amd64armhf, or arm64 and download the .deb file for the Docker CE version you want to install.

    Note: To install a nightly package, change the word stable in the URL to nightly. Learn about nightly and testchannels.

  2. Install Docker CE, changing the path below to the path where you downloaded the Docker package.

    $ sudo dpkg -i /path/to/package.deb
    

    The Docker daemon starts automatically.

  3. Verify that Docker CE is installed correctly by running the hello-world image.

    $ sudo docker run hello-world
    

    This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

Docker CE is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to Post-installation steps for Linux to allow non-privileged users to run Docker commands and for other optional configuration steps.

UPGRADE DOCKER CE

To upgrade Docker CE, download the newer package file and repeat the installation procedure, pointing to the new file.

Install using the convenience script

Docker provides convenience scripts at get.docker.com and test.docker.com for installing edge and testing versions of Docker CE into development environments quickly and non-interactively. The source code for the scripts is in the docker-install repository. Using these scripts is not recommended for production environments, and you should understand the potential risks before you use them:

  • The scripts require root or sudo privileges to run. Therefore, you should carefully examine and audit the scripts before running them.
  • The scripts attempt to detect your Linux distribution and version and configure your package management system for you. In addition, the scripts do not allow you to customize any installation parameters. This may lead to an unsupported configuration, either from Docker’s point of view or from your own organization’s guidelines and standards.
  • The scripts install all dependencies and recommendations of the package manager without asking for confirmation. This may install a large number of packages, depending on the current configuration of your host machine.
  • The script does not provide options to specify which version of Docker to install, and installs the latest version that is released in the “edge” channel.
  • Do not use the convenience script if Docker has already been installed on the host machine using another mechanism.

This example uses the script at get.docker.com to install the latest release of Docker CE on Linux. To install the latest testing version, use test.docker.com instead. In each of the commands below, replace each occurrence of get with test.

Warning:

Always examine scripts downloaded from the internet before running them locally.

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh


If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with something like:

  sudo usermod -aG docker your-user

Remember to log out and back in for this to take effect!

Warning:

Adding a user to the “docker” group grants them the ability to run containers which can be used to obtain root privileges on the Docker host. Refer to Docker Daemon Attack Surface for more information.

Docker CE is installed. It starts automatically on DEB-based distributions. On RPM-based distributions, you need to start it manually using the appropriate systemctl or service command. As the message indicates, non-root users can’t run Docker commands by default.

UPGRADE DOCKER AFTER USING THE CONVENIENCE SCRIPT

If you installed Docker using the convenience script, you should upgrade Docker using your package manager directly. There is no advantage to re-running the convenience script, and it can cause issues if it attempts to re-add repositories which have already been added to the host machine.

Uninstall Docker CE

  1. Uninstall the Docker CE package:

    $ sudo apt-get purge docker-ce
    
  2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

    $ sudo rm -rf /var/lib/docker
    

You must delete any edited configuration files manually.

Next steps

  • Continue to Post-installation steps for Linux
  • Continue with the User Guide.

requirements, apt, installation, debian, install, uninstall, upgrade, update

2.你看完了吗?妈耶,怎么这么多,看不懂怎么办?这都是些啥呀!!!(博主救我!!!)

好了,还是let it go吧。我贴出我的安装命令来。一步一步仔细看。 

安装大法:

longhai@poly:~$ docker
bash: docker: command not found
longhai@poly:~$ sudo apt-get update
[sudo] password for longhai: 
Get:1 http://packages.deepin.com/deepin panda InRelease [11.4 kB]
Get:2 https://deb.opera.com/opera-stable stable InRelease [2,591 B]
Get:3 https://deb.opera.com/opera-stable stable/non-free amd64 Packages [1,812 B]
Get:4 https://deb.opera.com/opera-stable stable/non-free i386 Packages [1,820 B]
Fetched 17.7 kB in 2s (9,140 B/s)    
Reading package lists... Done
longhai@poly:~$ sudo apt-get install \
>     apt-transport-https \
>     ca-certificates \
>     curl \
>     gnupg2 \
>     software-properties-common

Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-transport-https is already the newest version (1.6.3deepin).
ca-certificates is already the newest version (20180409).
The following additional packages will be installed:
  libappstream4 packagekit packagekit-tools python-apt-common python3-apt python3-pycurl
  python3-software-properties unattended-upgrades
Suggested packages:
  appstream python3-apt-dbg python-apt-doc libcurl4-gnutls-dev python-pycurl-doc python3-pycurl-dbg
  bsd-mailx default-mta | mail-transport-agent needrestart
The following NEW packages will be installed:
  curl gnupg2 libappstream4 packagekit packagekit-tools python-apt-common python3-apt python3-pycurl
  python3-software-properties software-properties-common unattended-upgrades
0 upgraded, 11 newly installed, 0 to remove and 1 not upgraded.
Need to get 1,904 kB of archives.
After this operation, 6,398 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://packages.deepin.com/deepin panda/main amd64 curl amd64 7.60.0-2deepin [253 kB]
Get:2 http://packages.deepin.com/deepin panda/main amd64 gnupg2 all 2.2.7-1 [380 kB]
Get:3 http://packages.deepin.com/deepin panda/main amd64 libappstream4 amd64 0.12.0-3 [103 kB]
Get:4 http://packages.deepin.com/deepin panda/main amd64 packagekit amd64 1.1.10-1 [590 kB]
Get:5 http://packages.deepin.com/deepin panda/main amd64 packagekit-tools amd64 1.1.10-1 [46.1 kB]         
Get:6 http://packages.deepin.com/deepin panda/main amd64 python-apt-common all 1.6.0 [93.5 kB]             
Get:7 http://packages.deepin.com/deepin panda/main amd64 python3-apt amd64 1.6.0 [177 kB]                  
Get:8 http://packages.deepin.com/deepin panda/main amd64 python3-pycurl amd64 7.43.0.1-0.2 [61.6 kB]       
Get:9 http://packages.deepin.com/deepin panda/main amd64 python3-software-properties all 0.96.20.2-1 [49.5 kB]
Get:10 http://packages.deepin.com/deepin panda/main amd64 software-properties-common all 0.96.20.2-1 [83.6 kB]
Get:11 http://packages.deepin.com/deepin panda/main amd64 unattended-upgrades all 1.2 [66.6 kB]            
Fetched 1,904 kB in 20s (93.4 kB/s)                                                                        
Preconfiguring packages ...
Selecting previously unselected package curl.
(Reading database ... 189750 files and directories currently installed.)
Preparing to unpack .../00-curl_7.60.0-2deepin_amd64.deb ...
Unpacking curl (7.60.0-2deepin) ...
Selecting previously unselected package gnupg2.
Preparing to unpack .../01-gnupg2_2.2.7-1_all.deb ...
Unpacking gnupg2 (2.2.7-1) ...
Selecting previously unselected package libappstream4:amd64.
Preparing to unpack .../02-libappstream4_0.12.0-3_amd64.deb ...
Unpacking libappstream4:amd64 (0.12.0-3) ...
Selecting previously unselected package packagekit.
Preparing to unpack .../03-packagekit_1.1.10-1_amd64.deb ...
Unpacking packagekit (1.1.10-1) ...
Selecting previously unselected package packagekit-tools.
Preparing to unpack .../04-packagekit-tools_1.1.10-1_amd64.deb ...
Unpacking packagekit-tools (1.1.10-1) ...
Selecting previously unselected package python-apt-common.
Preparing to unpack .../05-python-apt-common_1.6.0_all.deb ...
Unpacking python-apt-common (1.6.0) ...
Selecting previously unselected package python3-apt.
Preparing to unpack .../06-python3-apt_1.6.0_amd64.deb ...
Unpacking python3-apt (1.6.0) ...
Selecting previously unselected package python3-pycurl.
Preparing to unpack .../07-python3-pycurl_7.43.0.1-0.2_amd64.deb ...
Unpacking python3-pycurl (7.43.0.1-0.2) ...
Selecting previously unselected package python3-software-properties.
Preparing to unpack .../08-python3-software-properties_0.96.20.2-1_all.deb ...
Unpacking python3-software-properties (0.96.20.2-1) ...
Selecting previously unselected package software-properties-common.
Preparing to unpack .../09-software-properties-common_0.96.20.2-1_all.deb ...
Unpacking software-properties-common (0.96.20.2-1) ...
Selecting previously unselected package unattended-upgrades.
Preparing to unpack .../10-unattended-upgrades_1.2_all.deb ...
Unpacking unattended-upgrades (1.2) ...
Setting up python-apt-common (1.6.0) ...
Setting up python3-pycurl (7.43.0.1-0.2) ...
Setting up python3-apt (1.6.0) ...
Setting up libappstream4:amd64 (0.12.0-3) ...
Setting up curl (7.60.0-2deepin) ...
Setting up gnupg2 (2.2.7-1) ...
Processing triggers for libc-bin (2.27-3) ...
Processing triggers for systemd (238-5) ...
Setting up unattended-upgrades (1.2) ...

Creating config file /etc/apt/apt.conf.d/20auto-upgrades with new version

Creating config file /etc/apt/apt.conf.d/50unattended-upgrades with new version
Created symlink /etc/systemd/system/multi-user.target.wants/unattended-upgrades.service → /lib/systemd/system/unattended-upgrades.service.
Synchronizing state of unattended-upgrades.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable unattended-upgrades
Processing triggers for man-db (2.8.3-2) ...
Setting up python3-software-properties (0.96.20.2-1) ...
Processing triggers for dbus (1.12.8-2) ...
Setting up packagekit (1.1.10-1) ...
Setting up software-properties-common (0.96.20.2-1) ...
Setting up packagekit-tools (1.1.10-1) ...
Processing triggers for systemd (238-5) ...
Processing triggers for dbus (1.12.8-2) ...
longhai@poly:~$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
OK
longhai@poly:~$ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb)
sub   rsa4096 2017-02-22 [S]

longhai@poly:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian wheezy stable"
longhai@poly:~$ sudo apt-get update
Get:1 http://packages.deepin.com/deepin panda InRelease [11.4 kB]
Get:2 https://download.docker.com/linux/debian wheezy InRelease [15.3 kB]                                  
Get:3 https://download.docker.com/linux/debian wheezy/stable amd64 Packages [3,591 B]                      
Hit:4 https://deb.opera.com/opera-stable stable InRelease                          
Fetched 30.4 kB in 1s (32.3 kB/s)                
Reading package lists... Done
longhai@poly:~$ sudo apt-get install docker-ce
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aufs-tools cgroupfs-mount pigz
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount docker-ce pigz
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 50.4 MB of archives.
After this operation, 186 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://packages.deepin.com/deepin panda/main amd64 pigz amd64 2.4-1 [57.8 kB]
Get:2 http://packages.deepin.com/deepin panda/main amd64 aufs-tools amd64 1:4.9+20170918-2 [105 kB]
Get:3 https://download.docker.com/linux/debian wheezy/stable amd64 docker-ce amd64 18.03.1~ce-0~debian [50.2 MB]
Get:4 http://packages.deepin.com/deepin panda/main amd64 cgroupfs-mount all 1.4 [6,276 B]                  
Get:3 https://download.docker.com/linux/debian wheezy/stable amd64 docker-ce amd64 18.03.1~ce-0~debian [50.2 MB]
Fetched 47.0 MB in 2min 36s (301 kB/s)                                                                     
Selecting previously unselected package pigz.
(Reading database ... 190366 files and directories currently installed.)
Preparing to unpack .../archives/pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package aufs-tools.
Preparing to unpack .../aufs-tools_1%3a4.9+20170918-2_amd64.deb ...
Unpacking aufs-tools (1:4.9+20170918-2) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.4_all.deb ...
Unpacking cgroupfs-mount (1.4) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_18.03.1~ce-0~debian_amd64.deb ...
Unpacking docker-ce (18.03.1~ce-0~debian) ...
Setting up aufs-tools (1:4.9+20170918-2) ...
Setting up docker-ce (18.03.1~ce-0~debian) ...
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Setting up cgroupfs-mount (1.4) ...
Processing triggers for libc-bin (2.27-3) ...
Processing triggers for systemd (238-5) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up pigz (2.4-1) ...
longhai@poly:~$ systemctl start docker
longhai@poly:~$ docker version
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:13 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.37/version: dial unix /var/run/docker.sock: connect: permission denied
longhai@poly:~$ cat /etc/group | grep docker
docker:x:996:
longhai@poly:/var/run$ sudo chmod a+rw /var/run/docker.sock  
longhai@poly:/var/run$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

longhai@poly:/var/run$ 

3.好了,安装好了。大佬们,可以用Docker了。再见ヾ( ̄▽ ̄)Bye~Bye~

 

 

你可能感兴趣的:(Developing,Environment,Deploym)