How to Install Docker on CentOS/RHEL 8

Channel: Linux
Abstract: 46.861334755Z" level=info msg="Docker daemon" comm>Result ● docker.service - Docker Application Container Engine

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.

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 8Search 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.

Ref From: tecadmin

Related articles