Docker is one of virtualization type or technology which is used in the application level. It can be used to virtualize service or application running inside an operating system.
The motto of Docker is “Docker is the world’s leading software containerization platform” and it can be visited in the following URL of Docker official website.
Below is the step on installing docker on an operating system of CentOS 7.1511 :
1. Create docker repository file. It is normally created in /etc/yum.repos.d. Name the new repository file as ‘docker.repo’. Accomplish it using the following executable command :
vim /etc/yum.repos.d/docker.repo
Below is the executable command of the above line :
[root@hostname ~]# vim /etc/yum.repos.d/docker.repo
2. Execute the following command to clean all caches defined for the already defined repository. It is used to reload the cache and fill it with the new added repository entries. Execute the following command :
yum clean all
Below is the sample of the execution :
[root@hostname ~]# yum clean all Loaded plugins: fastestmirror Cleaning repos: base dockerrepo extras mysql-connectors-community mysql-tools-community mysql57-community updates Cleaning up everything Cleaning up list of fastest mirrors [root@hostname ~]# yum repolist Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 dockerrepo | 2.9 kB 00:00:00 extras | 3.4 kB 00:00:00 mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community | 2.5 kB 00:00:00 mysql57-community | 2.5 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/8): extras/7/x86_64/primary_db | 166 kB 00:00:00 (2/8): base/7/x86_64/group_gz | 155 kB 00:00:00 (3/8): dockerrepo/primary_db | 22 kB 00:00:00 (4/8): mysql-connectors-community/x86_64/primary_db | 11 kB 00:00:00 (5/8): base/7/x86_64/primary_db | 5.3 MB 00:00:00 (6/8): mysql-tools-community/x86_64/primary_db | 29 kB 00:00:00 (7/8): mysql57-community/x86_64/primary_db | 86 kB 00:00:00 (8/8): updates/7/x86_64/primary_db | 9.1 MB 00:00:00 Determining fastest mirrors * base: xxxxxxx.xxxxxxx.xxx * extras: xxxxxxxx.xxxxxxxxx.xxx * updates: xxxxxxxxxx.xxxxxxxxxxx.xxx repo id repo name status base/7/x86_64 CentOS-7 - Base 9.007 dockerrepo Docker Repository 65 extras/7/x86_64 CentOS-7 - Extras 393 mysql-connectors-community/x86_64 MySQL Connectors Community 24 mysql-tools-community/x86_64 MySQL Tools Community 38 mysql57-community/x86_64 MySQL 5.7 Community Server 146 updates/7/x86_64 CentOS-7 - Updates 2.560 repolist: 12.233 [root@hostname ~]#
3. Below is the command execution to install docker, using yum package manager tool since it is executed in CentOS :
yum -y install docker-engine
This is the execution in the command line :
[root@hostname ~]# yum -y install docker-engine Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: xxxxxxxxxxxxx.xxxxxxxxxx.xxx * extras: xxxxxxxxxxxxx.xxxxxxxxxxx.xxx * updates: xxxxxxxxxxxxxxx.xxxxxxxxxxx.xxx Resolving Dependencies --> Running transaction check ---> Package docker-engine.x86_64 0:1.12.3-1.el7.centos will be installed --> Processing Dependency: docker-engine-selinux >= 1.12.3-1.el7.centos for package: docker-engine-1.12.3-1.el7.centos.x86_64 --> Processing Dependency: libcgroup for package: docker-engine-1.12.3-1.el7.centos.x86_64 --> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-engine-1.12.3-1.el7.centos.x86_64 --> Processing Dependency: libltdl.so.7()(64bit) for package: docker-engine-1.12.3-1.el7.centos.x86_64 --> Running transaction check ---> Package docker-engine-selinux.noarch 0:1.12.3-1.el7.centos will be installed --> Processing Dependency: policycoreutils-python for package: docker-engine-selinux-1.12.3-1.el7.centos.noarch ---> Package libcgroup.x86_64 0:0.41-8.el7 will be installed ---> Package libseccomp.x86_64 0:2.2.1-1.el7 will be installed ---> Package libtool-ltdl.x86_64 0:2.4.2-21.el7_2 will be installed --> Running transaction check ---> Package policycoreutils-python.x86_64 0:2.2.5-20.el7 will be installed --> Processing Dependency: libsemanage-python >= 2.1.10-1 for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: python-IPy for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.2.5-20.el7.x86_64 --> Running transaction check ---> Package audit-libs-python.x86_64 0:2.4.1-5.el7 will be installed ---> Package checkpolicy.x86_64 0:2.1.12-6.el7 will be installed ---> Package libsemanage-python.x86_64 0:2.1.10-18.el7 will be installed ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed ---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================================================================== Installing: docker-engine x86_64 1.12.3-1.el7.centos dockerrepo 19 M Installing for dependencies: audit-libs-python x86_64 2.4.1-5.el7 base 69 k checkpolicy x86_64 2.1.12-6.el7 base 247 k docker-engine-selinux noarch 1.12.3-1.el7.centos dockerrepo 28 k libcgroup x86_64 0.41-8.el7 base 64 k libseccomp x86_64 2.2.1-1.el7 base 49 k libsemanage-python x86_64 2.1.10-18.el7 base 94 k libtool-ltdl x86_64 2.4.2-21.el7_2 updates 49 k policycoreutils-python x86_64 2.2.5-20.el7 base 435 k python-IPy noarch 0.75-6.el7 base 32 k setools-libs x86_64 3.3.7-46.el7 base 485 k Transaction Summary ================================================================================================================================================================================================================================== Install 1 Package (+10 Dependent packages) Total download size: 21 M Installed size: 84 M Downloading packages: (1/11): audit-libs-python-2.4.1-5.el7.x86_64.rpm | 69 kB 00:00:00 (2/11): libcgroup-0.41-8.el7.x86_64.rpm | 64 kB 00:00:00 (3/11): checkpolicy-2.1.12-6.el7.x86_64.rpm | 247 kB 00:00:00 (4/11): libseccomp-2.2.1-1.el7.x86_64.rpm | 49 kB 00:00:00 (5/11): libsemanage-python-2.1.10-18.el7.x86_64.rpm | 94 kB 00:00:00 (6/11): libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm | 49 kB 00:00:00 (7/11): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00 warning: /var/cache/yum/x86_64/7/dockerrepo/packages/docker-engine-selinux-1.12.3-1.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY Public key for docker-engine-selinux-1.12.3-1.el7.centos.noarch.rpm is not installed (8/11): docker-engine-selinux-1.12.3-1.el7.centos.noarch.rpm | 28 kB 00:00:00 (9/11): policycoreutils-python-2.2.5-20.el7.x86_64.rpm | 435 kB 00:00:00 (10/11): setools-libs-3.3.7-46.el7.x86_64.rpm | 485 kB 00:00:00 (11/11): docker-engine-1.12.3-1.el7.centos.x86_64.rpm | 19 MB 00:00:01 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 13 MB/s | 21 MB 00:00:01 Retrieving key from http://yum.dockerproject.org/gpg Importing GPG key 0x2C52609D: Userid : "Docker Release Tool (releasedocker) <[email protected]>" Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d From : http://yum.dockerproject.org/gpg Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libcgroup-0.41-8.el7.x86_64 1/11 Installing : audit-libs-python-2.4.1-5.el7.x86_64 2/11 Installing : libsemanage-python-2.1.10-18.el7.x86_64 3/11 Installing : libseccomp-2.2.1-1.el7.x86_64 4/11 Installing : python-IPy-0.75-6.el7.noarch 5/11 Installing : checkpolicy-2.1.12-6.el7.x86_64 6/11 Installing : libtool-ltdl-2.4.2-21.el7_2.x86_64 7/11 Installing : setools-libs-3.3.7-46.el7.x86_64 8/11 Installing : policycoreutils-python-2.2.5-20.el7.x86_64 9/11 Installing : docker-engine-selinux-1.12.3-1.el7.centos.noarch 10/11 restorecon: lstat(/var/lib/docker) failed: No such file or directory warning: %post(docker-engine-selinux-1.12.3-1.el7.centos.noarch) scriptlet failed, exit status 255 Non-fatal POSTIN scriptlet failure in rpm package docker-engine-selinux-1.12.3-1.el7.centos.noarch Installing : docker-engine-1.12.3-1.el7.centos.x86_64 11/11 Verifying : setools-libs-3.3.7-46.el7.x86_64 1/11 Verifying : libcgroup-0.41-8.el7.x86_64 2/11 Verifying : libtool-ltdl-2.4.2-21.el7_2.x86_64 3/11 Verifying : docker-engine-1.12.3-1.el7.centos.x86_64 4/11 Verifying : checkpolicy-2.1.12-6.el7.x86_64 5/11 Verifying : python-IPy-0.75-6.el7.noarch 6/11 Verifying : libseccomp-2.2.1-1.el7.x86_64 7/11 Verifying : libsemanage-python-2.1.10-18.el7.x86_64 8/11 Verifying : docker-engine-selinux-1.12.3-1.el7.centos.noarch 9/11 Verifying : policycoreutils-python-2.2.5-20.el7.x86_64 10/11 Verifying : audit-libs-python-2.4.1-5.el7.x86_64 11/11 Installed: docker-engine.x86_64 0:1.12.3-1.el7.centos Dependency Installed: audit-libs-python.x86_64 0:2.4.1-5.el7 checkpolicy.x86_64 0:2.1.12-6.el7 docker-engine-selinux.noarch 0:1.12.3-1.el7.centos libcgroup.x86_64 0:0.41-8.el7 libseccomp.x86_64 0:2.2.1-1.el7 libsemanage-python.x86_64 0:2.1.10-18.el7 libtool-ltdl.x86_64 0:2.4.2-21.el7_2 policycoreutils-python.x86_64 0:2.2.5-20.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.7-46.el7 Complete! [root@hostname ~]#
4. To start using docker, don’t forget to enable the service by executing the following command :
systemctl enable docker.service
This is the execution command for enabling docker service :
[root@hostname ~]# systemctl enable docker.service Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@hostname ~]#
5. After enabling docker service, run the following command to start the docker service :
systemctl start docker
Below is the command execution of starting docker service :
[root@hostname ~]# systemctl start docker
5. Check whether the docker service has already running and it is already successfully started by using the following command :
systemctl status docker.service
Type it to check the status of docker’s service :
[root@hostname ~]# systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-11-02 15:02:45 xxx; 5 days ago Docs: https://docs.docker.com Main PID: 1583 (dockerd) Memory: 43.3M CGroup: /system.slice/docker.service ├─1583 /usr/bin/dockerd └─2685 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libc... Nov 02 15:02:42 hostname dockerd[1583]: time="2016-11-02T15:02:42.863856134+07:00" level=info msg="Graph migration to content-addressability took 0.00 seconds" Nov 02 15:02:42 hostname dockerd[1583]: time="2016-11-02T15:02:42.865145333+07:00" level=warning msg="mountpoint for pids not found" Nov 02 15:02:42 hostname dockerd[1583]: time="2016-11-02T15:02:42.866014506+07:00" level=info msg="Loading containers: start." Nov 02 15:02:43 hostname dockerd[1583]: time="2016-11-02T15:02:43.152679856+07:00" level=info msg="Firewalld running: true" Nov 02 15:02:44 hostname dockerd[1583]: time="2016-11-02T15:02:44.889452805+07:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --b...ed IP address" Nov 02 15:02:45 hostname dockerd[1583]: time="2016-11-02T15:02:45.304987970+07:00" level=info msg="Loading containers: done." Nov 02 15:02:45 hostname dockerd[1583]: time="2016-11-02T15:02:45.311121008+07:00" level=info msg="Daemon has completed initialization" Nov 02 15:02:45 hostname dockerd[1583]: time="2016-11-02T15:02:45.311185155+07:00" level=info msg="Docker daemon" commit=6b644ec graphdriver=devicemapper version=1.12.3 Nov 02 15:02:45 hostname dockerd[1583]: time="2016-11-02T15:02:45.331454278+07:00" level=info msg="API listen on /var/run/docker.sock" Nov 02 15:02:45 hostname systemd[1]: Started Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full. [root@hostname ~]#
As it can be seen from the above output of command’s execution, the docker service has already started.
3 thoughts on “Install Docker in CentOS 7 via command line”