Featured image of post Installing Docker CE on CentOS and Ubuntu

Installing Docker CE on CentOS and Ubuntu

Installation methods for Docker CE: 1. Automatic installation: Use the official installation script (suitable for public network environments only). This official installation script...

Installation Methods for Docker CE

1. Automatic Installation: Use the Official Installation Script (Applicable for Public Network Environments Only)

The official installation script is compatible with all Linux systems, regardless of their distributions.

1
2
3
|  | curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun |
| --- | --- |
|  | After installation on CentOS, run sudo service docker start to start the service. |

2. Manual Installation: (Aliyun ECS can be installed via intranet, see comments for details)

Ubuntu 14.04 & 16.04 (Using apt-get for Installation)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|  | # Step 1: Install required system tools |
| --- | --- |
|  | sudo apt-get update |
|  | sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common |
|  | # Step 2: Install GPG certificate |
|  | curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - |
|  | # Step 3: Add repository information |
|  | sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" |
|  | # Step 4: Update package index and install Docker-CE |
|  | sudo apt-get -y update |
|  | sudo apt-get -y install docker-ce |
|  |  |
|  | Note: Additional considerations are below in the comments |
|  | # To install a specified version of Docker-CE: |
|  | # Step 1: Check available versions of Docker-CE: |
|  | # apt-cache madison docker-ce |
|  | #   docker-ce | 17.03.1~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages |
|  | #   docker-ce | 17.03.0~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages |
|  | # Step 2: Install a specified version of Docker-CE: (VERSION could be 17.03.1~ce-0~ubuntu-xenial as above) |
|  | # sudo apt-get -y install docker-ce=[VERSION] |
|  |  |
|  | # For installations via classic network or VPC network, replace the commands in Step 2 and Step 3 with the following |
|  | # Classic Network: |
|  | # curl -fsSL http://mirrors.aliyuncs.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - |
|  | # sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyuncs.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" |
|  | # VPC Network: |
|  | # curl -fsSL http://mirrors.cloud.aliyuncs.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add - |
|  | # sudo add-apt-repository "deb [arch=amd64] http://mirrors.cloud.aliyuncs.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" |

CentOS 7 (Using yum for Installation)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|  | # Step 1: Install required system tools |
| --- | --- |
|  | sudo yum install -y yum-utils device-mapper-persistent-data lvm2 |
|  | # Step 2: Add repository information |
|  | sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo |
|  | # Step 3: Update package index and install Docker-CE |
|  | sudo yum makecache fast |
|  | sudo yum -y install docker-ce |
|  | # Step 4: Start the Docker service |
|  | sudo service docker start |
|  |  |
|  | Note: Additional considerations are below in the comments |
|  | # The official repository defaults to the latest software. You can edit the repository to access specific versions. For example, the testing version is not available by default; you can enable it as follows: |
|  | # vim /etc/yum.repos.d/docker-ce.repo |
|  | #   Change enabled=0 under [docker-ce-test] to enabled=1 |
|  | # |
|  | # To install a specified version of Docker-CE: |
|  | # Step 1: Check available versions of Docker-CE: |
|  | # yum list docker-ce.x86_64 --showduplicates | sort -r |
|  | #   Loading mirror speeds from cached hostfile |
|  | #   Loaded plugins: branch, fastestmirror, langpacks |
|  | #   docker-ce.x86_64            17.03.1.ce-1.el7.centos            docker-ce-stable |
|  | #   docker-ce.x86_64            17.03.1.ce-1.el7.centos            @docker-ce-stable |
|  | #   docker-ce.x86_64            17.03.0.ce-1.el7.centos            docker-ce-stable |
|  | #   Available Packages |
|  | # Step 2: Install a specified version of Docker-CE: (VERSION could be 17.03.0.ce.1-1.el7.centos for example) |
|  | # sudo yum -y install docker-ce-[VERSION] |
|  | # Note: In some versions, additional dependencies are required for docker-ce installation. If installation fails, check the error messages. For example, after docker-ce 17.03, you need to install docker-ce-selinux first. |
|  | # yum list docker-ce-selinux- --showduplicates | sort -r |
|  | # sudo yum -y install docker-ce-selinux-[VERSION] |
|  |  |
|  | # For installations via classic network or VPC network, replace the commands in Step 2 with the following |
|  | # Classic Network: |
|  | # sudo yum-config-manager --add-repo http://mirrors.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo |
|  | # VPC Network: |
|  | # sudo yum-config-manager --add-repo http://mirrors.cloud.aliyuncs.com/docker-ce/linux/centos/docker-ce.repo |

Installation Verification

Run sudo docker version. If you see the following information, it indicates the installation was successful.

Installing Docker CE on CentOS and Ubuntu

For more information on Docker, you can check this link: https://bmzhp.com/knowledge/109

Licensed under CC BY-NC-SA 4.0