Cyberithub

How to Install Docker on CentOS 7 with Best Practices

Advertisements

In this article, I will take you through the steps to install docker on CentOS 7.

Docker is an open source software platform to create, deploy and manage virtualized application containers on a common operating system (OS), with an ecosystem of allied tools.

Docker Inc., the company that originally developed Docker, supports a commercial edition and is the principal sponsor of the open source tool.

How to Install Docker on CentOS 7 with Best Practices

Install Docker

Here are the simple steps to install docker in CentOS 7.

Prerequisites

Before trying to install Docker from binaries, make sure your machine meets the following prerequisites:-

a)A 64-bit installation
b)Version 3.10 or higher of the Linux kernel. The latest version of the kernel available for your platform is c)recommended.
d)iptables version 1.4 or higher
e)git version 1.7 or higher
f)A ps executable, usually provided by procps or a similar package.
g)XZ Utils 4.9 or higher

Upgrade packages through yum tool

First, we need to update our system using yum update command.

[root@localhost ~]# yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
No packages marked for update

Install Docker from yum repository

Now, we can directly install the docker package using yum install docker command.

[root@localhost ~]# yum install docker
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be installed
--> Processing Dependency: docker-common = 2:1.13.1-103.git7f2769b.el7.centos fo                                                                                        r package: 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: docker-client = 2:1.13.1-103.git7f2769b.el7.centos fo                                                                                        r package: 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: subscription-manager-rhsm-certificates for package: 2                                                                                        :docker-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Running transaction check
---> Package docker-client.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be ins                                                                                        talled
---> Package docker-common.x86_64 2:1.13.1-103.git7f2769b.el7.centos will be ins                                                                                        talled
--> Processing Dependency: skopeo-containers >= 1:0.1.26-2 for package: 2:docker                                                                                        -common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: oci-umount >= 2:2.3.3-3 for package: 2:docker-common-                                                                                        1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: oci-systemd-hook >= 1:0.1.4-9 for package: 2:docker-c                                                                                        ommon-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: oci-register-machine >= 1:0-5.13 for package: 2:docke                                                                                        r-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: container-storage-setup >= 0.9.0-1 for package: 2:doc                                                                                        ker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: container-selinux >= 2:2.51-1 for package: 2:docker-c                                                                                        ommon-1.13.1-103.git7f2769b.el7.centos.x86_64
--> Processing Dependency: atomic-registries for package: 2:docker-common-1.13.1                                                                                        -103.git7f2769b.el7.centos.x86_64
---> Package subscription-manager-rhsm-certificates.x86_64 0:1.24.13-3.el7.cento                                                                                        s will be installed
--> Running transaction check
---> Package atomic-registries.x86_64 1:1.22.1-29.gitb507039.el7 will be install                                                                                        ed
--> Processing Dependency: python-yaml for package: 1:atomic-registries-1.22.1-2                                                                                        9.gitb507039.el7.x86_64
--> Processing Dependency: python-setuptools for package: 1:atomic-registries-1.                                                                                        22.1-29.gitb507039.el7.x86_64
--> Processing Dependency: python-pytoml for package: 1:atomic-registries-1.22.1                                                                                        -29.gitb507039.el7.x86_64
---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selin                                                                                        ux-2.107-3.el7.noarch
---> Package container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 will be in                                                                                        stalled
---> Package containers-common.x86_64 1:0.1.37-3.el7.centos will be installed
---> Package oci-register-machine.x86_64 1:0-6.git2b44233.el7 will be installed
---> Package oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6 will be installe                                                                                        d
--> Processing Dependency: libyajl.so.2()(64bit) for package: 1:oci-systemd-hook                                                                                        -0.2.0-1.git05e6923.el7_6.x86_64
---> Package oci-umount.x86_64 2:2.5-3.el7 will be installed
--> Running transaction check
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.e                                                                                        l7.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-33.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-                                                                                        python-2.5-33.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreu                                                                                        tils-python-2.5-33.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreu                                                                                        tils-python-2.5-33.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-33                                                                                        .el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycore                                                                                        utils-python-2.5-33.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycore                                                                                        utils-python-2.5-33.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-33.                                                                                        el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycore                                                                                        utils-python-2.5-33.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-3                                                                                        3.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-py                                                                                        thon-2.5-33.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-py                                                                                        thon-2.5-33.el7.x86_64
---> Package python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 will be installed
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: pyth                                                                                        on-setuptools-0.9.8-7.el7.noarch
---> Package yajl.x86_64 0:2.0.4-4.el7 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be                                                                                         installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_ma                                                                                        tch_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_ma                                                                                        tch_hostname-3.5.0.1-1.el7.noarch
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch   Version                            Repository
                                                                           Size
================================================================================
Installing:
 docker                 x86_64 2:1.13.1-103.git7f2769b.el7.centos extras   18 M
Installing for dependencies:
 PyYAML                 x86_64 3.10-11.el7                        base    153 k
 atomic-registries      x86_64 1:1.22.1-29.gitb507039.el7         extras   35 k
 audit-libs-python      x86_64 2.8.5-4.el7                        base     76 k
 checkpolicy            x86_64 2.5-8.el7                          base    295 k
 container-selinux      noarch 2:2.107-3.el7                      extras   39 k
 container-storage-setup
                        noarch 0.11.0-2.git5eaf76c.el7            extras   35 k
 containers-common      x86_64 1:0.1.37-3.el7.centos              extras   21 k
 docker-client          x86_64 2:1.13.1-103.git7f2769b.el7.centos extras  3.9 M
 docker-common          x86_64 2:1.13.1-103.git7f2769b.el7.centos extras   97 k
 libcgroup              x86_64 0.41-21.el7                        base     66 k
 libsemanage-python     x86_64 2.5-14.el7                         base    113 k
 libyaml                x86_64 0.1.4-11.el7_0                     base     55 k
 oci-register-machine   x86_64 1:0-6.git2b44233.el7               extras  1.1 M
 oci-systemd-hook       x86_64 1:0.2.0-1.git05e6923.el7_6         extras   34 k
 oci-umount             x86_64 2:2.5-3.el7                        extras   33 k
 policycoreutils-python x86_64 2.5-33.el7                         base    457 k
 python-IPy             noarch 0.75-6.el7                         base     32 k
 python-backports       x86_64 1.0-8.el7                          base    5.8 k
 python-backports-ssl_match_hostname
                        noarch 3.5.0.1-1.el7                      base     13 k
 python-ipaddress       noarch 1.0.16-2.el7                       base     34 k
 python-pytoml          noarch 0.1.14-1.git7dea353.el7            extras   18 k
 python-setuptools      noarch 0.9.8-7.el7                        base    397 k
 setools-libs           x86_64 3.3.8-4.el7                        base    620 k
 subscription-manager-rhsm-certificates
                        x86_64 1.24.13-3.el7.centos               updates 228 k
 yajl                   x86_64 2.0.4-4.el7                        base     39 k

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

Total download size: 25 M
Installed size: 89 M
Is this ok [y/d/N]: y
Downloading packages:
(1/26): PyYAML-3.10-11.el7.x86_64.rpm                                                                                                            | 153 kB  00:00:00
(2/26): container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm                                                                               |  35 kB  00:00:00
(3/26): atomic-registries-1.22.1-29.gitb507039.el7.x86_64.rpm                                                                                    |  35 kB  00:00:00
(4/26): containers-common-0.1.37-3.el7.centos.x86_64.rpm                                                                                         |  21 kB  00:00:00
(5/26): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                         | 295 kB  00:00:00
(6/26): container-selinux-2.107-3.el7.noarch.rpm                                                                                                 |  39 kB  00:00:00
(7/26): audit-libs-python-2.8.5-4.el7.x86_64.rpm                                                                                                 |  76 kB  00:00:00
(8/26): docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64.rpm                                                                                | 3.9 MB  00:00:03
(9/26): docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64.rpm                                                                                |  97 kB  00:00:00
(10/26): libcgroup-0.41-21.el7.x86_64.rpm                                                                                                        |  66 kB  00:00:00
(11/26): docker-1.13.1-103.git7f2769b.el7.centos.x86_64.rpm                                                                                      |  18 MB  00:00:04
(12/26): oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64.rpm                                                                                    |  34 kB  00:00:00
(13/26): libyaml-0.1.4-11.el7_0.x86_64.rpm                                                                                                       |  55 kB  00:00:00
(14/26): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                | 113 kB  00:00:00
(15/26): oci-umount-2.5-3.el7.x86_64.rpm                                                                                                         |  33 kB  00:00:00
(16/26): python-IPy-0.75-6.el7.noarch.rpm                                                                                                        |  32 kB  00:00:00
(17/26): policycoreutils-python-2.5-33.el7.x86_64.rpm                                                                                            | 457 kB  00:00:00
(18/26): python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm                                                                                        |  18 kB  00:00:00
(19/26): python-ipaddress-1.0.16-2.el7.noarch.rpm                                                                                                |  34 kB  00:00:00
(20/26): python-backports-1.0-8.el7.x86_64.rpm                                                                                                   | 5.8 kB  00:00:00
(21/26): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm                                                                            |  13 kB  00:00:00
(22/26): subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64.rpm                                                                  | 228 kB  00:00:00
(23/26): python-setuptools-0.9.8-7.el7.noarch.rpm                                                                                                | 397 kB  00:00:00
(24/26): yajl-2.0.4-4.el7.x86_64.rpm                                                                                                             |  39 kB  00:00:00
(25/26): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                     | 620 kB  00:00:02
(26/26): oci-register-machine-0-6.git2b44233.el7.x86_64.rpm                                                                                      | 1.1 MB  00:00:05
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                   2.7 MB/s |  25 MB  00:00:09
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : yajl-2.0.4-4.el7.x86_64                                                                                                                             1/26
  Installing : 2:oci-umount-2.5-3.el7.x86_64                                                                                                                       2/26
  Installing : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                                                                                  3/26
  Installing : libcgroup-0.41-21.el7.x86_64                                                                                                                        4/26
  Installing : subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64                                                                                  5/26
  Installing : python-ipaddress-1.0.16-2.el7.noarch                                                                                                                6/26
  Installing : libyaml-0.1.4-11.el7_0.x86_64                                                                                                                       7/26
  Installing : PyYAML-3.10-11.el7.x86_64                                                                                                                           8/26
  Installing : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                                9/26
  Installing : python-backports-1.0-8.el7.x86_64                                                                                                                  10/26
  Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                                                                           11/26
  Installing : python-setuptools-0.9.8-7.el7.noarch                                                                                                               12/26
  Installing : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                                                                                   13/26
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                               14/26
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                    15/26
  Installing : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                                                                                       16/26
  Installing : 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64                                                                                                17/26
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                       18/26
  Installing : 1:containers-common-0.1.37-3.el7.centos.x86_64                                                                                                     19/26
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                       20/26
  Installing : policycoreutils-python-2.5-33.el7.x86_64                                                                                                           21/26
  Installing : 2:container-selinux-2.107-3.el7.noarch                                                                                                             22/26
  Installing : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                                                                             23/26
  Installing : 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64                                                                                            24/26
  Installing : 2:docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64                                                                                            25/26
  Installing : 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64                                                                                                   26/26
  Verifying  : 2:docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64                                                                                             1/26
  Verifying  : 2:docker-1.13.1-103.git7f2769b.el7.centos.x86_64                                                                                                    2/26
  Verifying  : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch                                                                                            3/26
  Verifying  : 2:container-selinux-2.107-3.el7.noarch                                                                                                              4/26
  Verifying  : container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch                                                                                              5/26
  Verifying  : 1:atomic-registries-1.22.1-29.gitb507039.el7.x86_64                                                                                                 6/26
  Verifying  : python-setuptools-0.9.8-7.el7.noarch                                                                                                                7/26
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                        8/26
  Verifying  : 2:oci-umount-2.5-3.el7.x86_64                                                                                                                       9/26
  Verifying  : 1:containers-common-0.1.37-3.el7.centos.x86_64                                                                                                     10/26
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                       11/26
  Verifying  : python-pytoml-0.1.14-1.git7dea353.el7.noarch                                                                                                       12/26
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                    13/26
  Verifying  : policycoreutils-python-2.5-33.el7.x86_64                                                                                                           14/26
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                               15/26
  Verifying  : 1:oci-systemd-hook-0.2.0-1.git05e6923.el7_6.x86_64                                                                                                 16/26
  Verifying  : 2:docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64                                                                                            17/26
  Verifying  : 1:oci-register-machine-0-6.git2b44233.el7.x86_64                                                                                                   18/26
  Verifying  : python-backports-1.0-8.el7.x86_64                                                                                                                  19/26
  Verifying  : yajl-2.0.4-4.el7.x86_64                                                                                                                            20/26
  Verifying  : audit-libs-python-2.8.5-4.el7.x86_64                                                                                                               21/26
  Verifying  : libyaml-0.1.4-11.el7_0.x86_64                                                                                                                      22/26
  Verifying  : python-ipaddress-1.0.16-2.el7.noarch                                                                                                               23/26
  Verifying  : PyYAML-3.10-11.el7.x86_64                                                                                                                          24/26
  Verifying  : subscription-manager-rhsm-certificates-1.24.13-3.el7.centos.x86_64                                                                                 25/26
  Verifying  : libcgroup-0.41-21.el7.x86_64                                                                                                                       26/26

Installed:
  docker.x86_64 2:1.13.1-103.git7f2769b.el7.centos

Dependency Installed:
  PyYAML.x86_64 0:3.10-11.el7                                                   atomic-registries.x86_64 1:1.22.1-29.gitb507039.el7
  audit-libs-python.x86_64 0:2.8.5-4.el7                                        checkpolicy.x86_64 0:2.5-8.el7
  container-selinux.noarch 2:2.107-3.el7                                        container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7
  containers-common.x86_64 1:0.1.37-3.el7.centos                                docker-client.x86_64 2:1.13.1-103.git7f2769b.el7.centos
  docker-common.x86_64 2:1.13.1-103.git7f2769b.el7.centos                       libcgroup.x86_64 0:0.41-21.el7
  libsemanage-python.x86_64 0:2.5-14.el7                                        libyaml.x86_64 0:0.1.4-11.el7_0
  oci-register-machine.x86_64 1:0-6.git2b44233.el7                              oci-systemd-hook.x86_64 1:0.2.0-1.git05e6923.el7_6
  oci-umount.x86_64 2:2.5-3.el7                                                 policycoreutils-python.x86_64 0:2.5-33.el7
  python-IPy.noarch 0:0.75-6.el7                                                python-backports.x86_64 0:1.0-8.el7
  python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7                    python-ipaddress.noarch 0:1.0.16-2.el7
  python-pytoml.noarch 0:0.1.14-1.git7dea353.el7                                python-setuptools.noarch 0:0.9.8-7.el7
  setools-libs.x86_64 0:3.3.8-4.el7                                             subscription-manager-rhsm-certificates.x86_64 0:1.24.13-3.el7.centos
  yajl.x86_64 0:2.0.4-4.el7

Complete!

Check from the rpm database if docker is installed or not

Once installation completed, Check if it is installed or not using rpm command.

[root@localhost ~]# rpm -qa | grep -i docker
docker-client-1.13.1-103.git7f2769b.el7.centos.x86_64
docker-common-1.13.1-103.git7f2769b.el7.centos.x86_64
docker-1.13.1-103.git7f2769b.el7.centos.x86_64

Check the Docker version

Finally once the docker installation is completed, you can check the docker version using docker -v command.

[root@localhost ~]# docker -v
Docker version 1.13.1, build 7f2769b/1.13.1

For more info: Docker Documentation

Also Read: Cloud IaaS Setup

Leave a Comment