Docker is an OS level virtualization platform used for container-based application. Which wrap of a specific application with all its dependencies in a container. Docker containers can easily ship to a remote location on start there without making entire application setup. This tutorial will help you to install and manage Docker community edition on CentOS/RHEL 8 Linux system.

Advertisement

Step 1 – Enable Docker Repository

First of all, add the official Docker yum repository on your CentOS 8 system.

sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Step 2 – Install Docker on CentOS 8

After adding the yum repository to your CentOS system, update the yum cache by executing the following command.

sudo dnf makecache

Now install docker community edition package to install docker on your system. This is installed many of the required decencies on your system.

sudo dnf install --nobest docker-ce

The –nobest option instruct installer to not to limit for best candidate package dependency.

Step 3 – Manage Docker Service

Once the Docker successfully installed on your CentOS 8 system. Use the following commands to enable Docker serivce and start it.

sudo systemctl enable docker.service
sudo systemctl start docker.service

Then check the Docker service status.

sudo systemctl status docker.service

Result

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-04-10 05:26:46 UTC; 1s ago
     Docs: https://docs.docker.com
 Main PID: 23263 (dockerd)
    Tasks: 18
   Memory: 50.0M
   CGroup: /system.slice/docker.service
           ├─23263 /usr/bin/dockerd -H fd://
           └─23275 containerd --config /var/run/docker/containerd/containerd.toml --log-level info

Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.439527082Z" level=info msg="Graph migration to >
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.440174585Z" level=warning msg="Your kernel does>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.440197735Z" level=warning msg="Your kernel does>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.440723426Z" level=info msg="Loading containers:>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.677587189Z" level=info msg="Default bridge (doc>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.801904550Z" level=info msg="Loading containers:>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.861334755Z" level=info msg="Docker daemon" comm>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.864579987Z" level=info msg="Daemon has complete>
Apr 10 05:26:46 tecadmin dockerd[23263]: time="2020-04-10T05:26:46.881460358Z" level=info msg="API listen on /var/>
Apr 10 05:26:46 tecadmin systemd[1]: Started Docker Application Container Engine.

Docker has been installed and running on your CentOS 8 operating system. You can visit our Docker tutorial section to work with Docker containers.

Step 4 – Test Docker on CentOS 8

Search Docker Images

First of all search Docker container images from Docker hub. For example, below command will search all images with Ubuntu and list as output

sudo docker search hello-world

Download Docker Images

Now download the Docker container with name Ubuntu on your local system using following commands.

sudo docker pull hello-world

Output:

Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

Now make sure that above images have been downloaded successfully on your system. Below command list all images.

sudo docker images

Output:

REPOSITORY          TAG          IMAGE ID          CREATED             SIZE
centos              latest       470671670cac      2 months ago        237MB
hello-world         latest       fce289e99eb9      15 months ago       1.84kB

Run Hello-World Docker Container

Use the following command to run a hello-world docker container. This container will print a message on screen and exit immediately.

docker run -i hello-world

You will see the results like below screenshot. The success message shows that Docker service is properly installed on your CentOS 8 system.

Install Docker CentOS 8

Share.

3 Comments

  1. vinsent paramanantham on

    This was a really a time saver. I was roaming for more the 30mins.. you made it simple, Good to have you in the tech community. Thanking you.

  2. Ibrahim Elamin on

    HI Rahul,

    Thanks for the great post. I am getting an error when running the=e following command:

    [osboxes@osboxes ~]$ sudo dnf install –nobest docker-ce

    created by dnf config-manager from https://downlo 1.3 kB/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for https://download.docker.com/linux/centos/repodata/repomd.xml (IP: 99.86.61.58)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

    Your advice is appreciated..

    Regards,

  3. This blog post should be at the top of the Google search. I spent the entire day today trying to install Docker on RHEL 8. Apparently from what I read, RedHat doesn’t like Docker because it wants its users to lock-in to their platform?

    I wasted so much time trying to get it to install Docker today. Through other guides, I was able to install Docker, but the installation was faulty, as Docker processes wouldn’t run. (RHEL 8.3, Docker 20.10.2) This guide finally helped me install Docker.

    THANK YOU, Rahul, for the informative post!

Leave A Reply

Exit mobile version