Site icon UnixArena

How to Install docker on Redhat Linux (RHEL)- CentOS ?

Docker on Virtual Machine

Docker on Virtual Machine

How to install docker on Redhat Linux (RHEL) and CentOS? How to setup the docker environment to start the first container to start exploring the container world?  In this article, we are going to demonstrate the docker community edition deployment on RHEL/CentOS. We will also launch the Docker containers to test the deployment.

 

Docker Editions

Docker Community Edition

 

                                                  Docker Enterprise Edition – Supported OS

 

Docker glossary

Check out more glossary here.

 

Pre-requisites:

1. Docker supports only x86_64 (64-bit architecture). It also required Linux kernel version 3.8 and above. You could verify the system architecture and kernel version using the following command.

[root@uaweb1 ~]# uname -ir
3.10.0-123.el7.x86_64 x86_64
[root@uaweb1 ~]#

 

2. Ensure that system is installed with following packages.

[root@uaweb1 ~]# rpm -qa | egrep "mapper|lvm2|device-mapper-persistent-data|yum-utils"
device-mapper-event-libs-1.02.84-14.el7.x86_64
device-mapper-libs-1.02.84-14.el7.x86_64
lvm2-libs-2.02.105-14.el7.x86_64
device-mapper-persistent-data-0.3.2-1.el7.x86_64
lvm2-2.02.105-14.el7.x86_64
device-mapper-1.02.84-14.el7.x86_64
device-mapper-event-1.02.84-14.el7.x86_64
yum-utils-1.1.31-24.el7.noarch
[root@uaweb1 ~]#

 

If not, please install the missing packages using yum command.

#  yum install -y device-mapper-persistent-data lvm2 device-mapper yum-utils

 

Setting up the Docker Repository:

Configure the docker repository by pulling the repo file form docker website and save it in /etc/yum.repos.d directory. The following command does all the actions for you.

[root@uaweb1 yum.repos.d]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: langpacks, product-id
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
[root@uaweb1 yum.repos.d]#

 

Note: Docker community edition is not available for RHEL. However, Docker provides the community edition for Centos which also can be installed on RHEL. But it’s unsupported.

 

Installing Docker:

Once the repo is configured successfully, we are good to install docker community edition.

# yum install docker-ce

Running transaction
  Installing : libcgroup-0.41-15.el7.x86_64                                                                                                                        1/11
  Installing : pigz-2.3.3-1.el7.centos.x86_64                                                                                                                      2/11
  Installing : audit-libs-python-2.8.1-3.el7.x86_64                                                                                                                3/11
  Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                                  4/11
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                        5/11
  Installing : checkpolicy-2.5-6.el7.x86_64                                                                                                                        6/11
  Installing : libsemanage-python-2.5-11.el7.x86_64                                                                                                                7/11
  Installing : setools-libs-3.3.8-2.el7.x86_64                                                                                                                     8/11
  Installing : policycoreutils-python-2.5-22.el7.x86_64                                                                                                            9/11
  Installing : 2:container-selinux-2.55-1.el7.noarch                                                                                                              10/11
  Installing : docker-ce-18.03.1.ce-1.el7.centos.x86_64                                                                                                           11/11
  Verifying  : libcgroup-0.41-15.el7.x86_64                                                                                                                        1/11
  Verifying  : docker-ce-18.03.1.ce-1.el7.centos.x86_64                                                                                                            2/11
  Verifying  : setools-libs-3.3.8-2.el7.x86_64                                                                                                                     3/11
  Verifying  : policycoreutils-python-2.5-22.el7.x86_64                                                                                                            4/11
  Verifying  : libsemanage-python-2.5-11.el7.x86_64                                                                                                                5/11
  Verifying  : 2:container-selinux-2.55-1.el7.noarch                                                                                                               6/11
  Verifying  : checkpolicy-2.5-6.el7.x86_64                                                                                                                        7/11
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                        8/11
  Verifying  : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                                                                  9/11
  Verifying  : audit-libs-python-2.8.1-3.el7.x86_64                                                                                                               10/11
  Verifying  : pigz-2.3.3-1.el7.centos.x86_64                                                                                                                     11/11

Installed:
  docker-ce.x86_64 0:18.03.1.ce-1.el7.centos

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.1-3.el7   checkpolicy.x86_64 0:2.5-6.el7         container-selinux.noarch 2:2.55-1.el7   libcgroup.x86_64 0:0.41-15.el7
  libsemanage-python.x86_64 0:2.5-11.el7   libtool-ltdl.x86_64 0:2.4.2-22.el7_3   pigz.x86_64 0:2.3.3-1.el7.centos        policycoreutils-python.x86_64 0:2.5-22.el7
  python-IPy.noarch 0:0.75-6.el7           setools-libs.x86_64 0:3.3.8-2.el7

Complete!
[root@node1 ~]#

 

You might get following errors on Redhat Enterprise Linux (RHEL)

Error: Package: docker-ce-18.03.1.ce-1.el7.centos.x86_64 (docker-ce-stable)
Requires: pigz
Error: Package: docker-ce-18.03.1.ce-1.el7.centos.x86_64 (docker-ce-stable)
Requires: container-selinux >= 2.9
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest

 

To fix above mentioned error,

Redhat Linux (RHEL 7) requires extra rpms. Enable the extras RHEL repository. This ensures access to the container-selinux package which is required by docker-ce. It requires a Red hat subscription.

# yum-config-manager --enable rhel-7-server-extras-rpms

 

Start the Docker service

Once the installation is done, you need to start the docker service manually.

[root@node1 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://docs.docker.com
[root@node1 ~]# systemctl start  docker
[root@node1 ~]#

 

To start the docker service on startup,

[root@node1 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@node1 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-06-15 11:31:43 PDT; 21s ago
     Docs: https://docs.docker.com
 Main PID: 1598 (dockerd)
   CGroup: /system.slice/docker.service
           ├─1598 /usr/bin/dockerd
           └─1602 docker-containerd --config /var/run/docker/containerd/containerd.toml

 

Verify the docker Installation:

The most common way to test the docker is, running image “hello-world” .

[root@node1 ~]# docker run -it hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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/engine/userguide/

[root@node1 ~]#

 

We have successfully installed docker community edition on RHEL/CentOS.

Exit mobile version