Setting up a docker environment under CentOS7.4

Keywords: Docker CentOS yum SELinux

Docker uses timeline as version number after version 1.13, which is divided into community version CE and enterprise version EE.
The community version is free for individual developers and small groups. The enterprise version will provide additional charging services, such as infrastructure, containers, plug-ins, etc. that have been officially tested and certified.
The community version is released in two ways: stable and edge. The stable version is updated quarterly, such as 18.03 and 18.06. The edge version is updated monthly, such as 18.06 and 18.07.

Docker installation

  • Docker requires the kernel version of CentOS system to be higher than 3.10. Check the prerequisites on this page to verify whether your CentOS version supports docker.
    Check your current kernel version with the uname -r command
[root@ecs-a30e-0002 ~]# uname -r
3.10.0-693.11.1.el7.x86_64
  • Log in to Centos with root privileges. Make sure the yum package is updated to the latest.
[root@ecs-a30e-0002 ~]# yum update
  • Uninstall the old version (if the old version has been installed)
[root@ecs-a30e-0002 ~]# yum remove docker  docker-common docker-selinux docker-engine
  • Install the required software package. Yum util provides the function of Yum config manager. The other two are dependent on the device mapper driver
[root@ecs-a30e-0002 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
  • Set the yum source of docker
[root@ecs-a30e-0002 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
  • You can view all docker versions in all warehouses and select a specific version to install
[root@ecs-a30e-0002 ~]# yum list docker-ce --showduplicates | sort -r
 * updates: mirror.bit.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
 * extras: mirrors.huaweicloud.com
 * epel: mirrors.huaweicloud.com
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.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
 * base: mirror.bit.edu.cn
Available Packages
  • Install docker
$ sudo yum install docker-ce  #Since only stable warehouse is opened in repo by default, the latest stable version 17.12.0 is installed here


[root@ecs-a30e-0002 ~]# yum install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * epel: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirror.bit.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.06.1.ce-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Processing Dependency: libseccomp >= 2.3 for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-18.06.1.ce-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.68-1.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be installed
---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================
 Package                                   Arch                           Version                                    Repository                                Size
====================================================================================================================================================================
Installing:
 docker-ce                                 x86_64                         18.06.1.ce-3.el7                           docker-ce-stable                          41 M
Installing for dependencies:
 container-selinux                         noarch                         2:2.68-1.el7                               extras                                    36 k
 libseccomp                                x86_64                         2.3.1-3.el7                                base                                      56 k
 libtool-ltdl                              x86_64                         2.4.2-22.el7_3                             base                                      49 k

Transaction Summary
====================================================================================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 41 M
Installed size: 41 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): container-selinux-2.68-1.el7.noarch.rpm                                                                                               |  36 kB  00:00:00     
(2/4): libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm                                                                                                |  49 kB  00:00:00     
(3/4): libseccomp-2.3.1-3.el7.x86_64.rpm                                                                                                     |  56 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.06.1.ce-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY0:00:00 ETA 
Public key for docker-ce-18.06.1.ce-3.el7.x86_64.rpm is not installed
(4/4): docker-ce-18.06.1.ce-3.el7.x86_64.rpm                                                                                                 |  41 MB  00:13:30     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                52 kB/s |  41 MB  00:13:30     
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libseccomp-2.3.1-3.el7.x86_64                                                                                                                    1/4 
  Installing : 2:container-selinux-2.68-1.el7.noarch                                                                                                            2/4 
setsebool:  SELinux is disabled.
  Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                               3/4 
  Installing : docker-ce-18.06.1.ce-3.el7.x86_64                                                                                                                4/4 
  Verifying  : docker-ce-18.06.1.ce-3.el7.x86_64                                                                                                                1/4 
  Verifying  : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                               2/4 
  Verifying  : 2:container-selinux-2.68-1.el7.noarch                                                                                                            3/4 
  Verifying  : libseccomp-2.3.1-3.el7.x86_64                                                                                                                    4/4 

Installed:
  docker-ce.x86_64 0:18.06.1.ce-3.el7                                                                                                                               

Dependency Installed:
  container-selinux.noarch 2:2.68-1.el7                   libseccomp.x86_64 0:2.3.1-3.el7                   libtool-ltdl.x86_64 0:2.4.2-22.el7_3                  

Complete!
  • Start up and join start up
[root@ecs-a30e-0002 ~]# systemctl start docker
[root@ecs-a30e-0002 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
  • Verify whether the installation is successful (two parts, client and service, indicate that the installation and startup of docker are successful)
[root@ecs-a30e-0002 ~]# docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:23:03 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:25:29 2018
  OS/Arch:          linux/amd64
  Experimental:     false

All installation methods refer to Here , I record while installing

Posted by DimeDropper on Wed, 01 Jan 2020 01:48:09 -0800