How can install Docker on RHEL 7 / CentOS 7 Linux machine?. Containers have revolutionized Applications deployment and massive scalability of microservices. Docker was a game-changer, simplifying the process of running and managing applications in containers. This article will guide you through the installation of Docker on RHEL 7.

For CentOS 7, check Docker Installation on CentOS 7

Step 1: Register your RHEL 7 server

Start by registering your RHEL 7 server with Red Hat Subscription Management or Satellite server.

sudo subscription-manager register --auto-attach

Input your username and password when prompted.

Step 2: Enable required repositories

After registering the system, enable RHEL 7 repositories which have Docker packages and dependencies.

sudo subscription-manager repos --enable=rhel-7-server-rpms \
  --enable=rhel-7-server-extras-rpms \
  --enable=rhel-7-server-optional-rpms

Step 3: Install Docker on RHEL 7

We can now Install Docker on RHEL 7 by running the commands below.

sudo yum install -y docker device-mapper-libs device-mapper-event-libs
sudo systemctl enable --now docker.service

Confirm service status.

$ 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 Thu 2023-08-24 12:38:09 UTC; 49s ago
     Docs: http://docs.docker.com
 Main PID: 1664 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─1664 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-...
           └─1670 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontaine...

Aug 24 12:38:08 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:08.072923810Z" level=info msg="libcontainerd: new containerd process, pid: 1670"
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.189090367Z" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.190612187Z" level=info msg="Loading containers: start."
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.271116538Z" level=info msg="Firewalld running: false"
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.401669425Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daem... IP address"
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.454871910Z" level=info msg="Loading containers: done."
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.492523464Z" level=info msg="Daemon has completed initialization"
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.492580166Z" level=info msg="Docker daemon" commit="7d71120/1.13.1" graphdriver=overlay2 version=1.13.1
Aug 24 12:38:09 cent7.mylab.io dockerd-current[1664]: time="2023-08-24T12:38:09.508536138Z" level=info msg="API listen on /var/run/docker.sock"
Aug 24 12:38:09 cent7.mylab.io systemd[1]: Started Docker Application Container Engine.
.......

Step 4: Setting insecure registries

If you have local Docker registries without SSL encryption for access, you may need to whitelist them.

$ sudo vi /etc/containers/registries.conf
[registries.insecure]
registries = ["reg1.example.com","reg2.example.com"]

To block access to a registry, add the registry URL under registries.block section.

[registries.block]
registries = ['reg10.example.com']

Restart docker service if you make a change to the configuration file.

sudo systemctl restart docker

Test Docker installation.

# docker pull hello-world
Using default tag: latest
Trying to pull repository registry.access.redhat.com/hello-world ... 
Pulling repository registry.access.redhat.com/hello-world
Trying to pull repository docker.io/library/hello-world ... 
latest: Pulling from docker.io/library/hello-world
1b930d010525: Pull complete 
Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
Status: Downloaded newer image for docker.io/hello-world:latest

# docker run --rm hello-world
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/get-started/

You now have Docker installed on RHEL 7 system. Happy containerization.

Also, check:

LEAVE A REPLY

Please enter your comment!
Please enter your name here