We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install Docker CE & Docker Compose on CentOS 8 | RHEL 8

Learn how to – Install Docker CE & Docker Compose on CentOS 8 | RHEL 8.

In this guide we’ll be walking you through the steps of installing Docker CE on CentOS 8 | RHEL 8. We’ll also cover how to install Docker Compose on RHEL 8 / CentOS 8 Linux?. Docker is not officially supported on RHEL 8 as it has been replaced with Red Hat tools – buildah and podman. You can learn more about new features witnessed in release of RHEL 8 Linux.

But what if you use Docker every single day and can’t switch to buildah and podman immediately?, don’t worry since there is a way to install Docker and Docker Compose on RHEL 8 / CentOS 8. Docker is a tool that enables you to create, deploy and run your applications in containers. Containers allow a Developer to package an application with its dependencies and ship it out as a single package. Containers are often used in Microservices environments.

Docker Components / Terminologies

There is a number of Docker specific jargon that we need to clarify before diving into installation and usage examples. Below are commonly used terminologies in Docker ecosystem.

  • Docker daemon: This is also called Docker Engine, it is a background process which runs on the host system responsible for building and running of containers.
  • Docker Client: This is a command line tool used by the user to interact with the Docker daemon.
  • Docker Image: An image is an immutable file that’s essentially a snapshot of a container. A docker image has a file system and application dependencies required for running applications.
  • Docker container: This is a running instance of a docker image with an application and its dependencies. Each container has a unique process ID and isolated from other containers. The only thing containers share is the Kernel.
  • Docker registry: This is an application responsible for managing storage and delivery of Docker container images. It can be private or public.

Install Docker CE on CentOS 8 | RHEL 8

So far we have covered docker introduction and terminologies. We should be ready to install Docker CE on RHEL 8 / CentOS 8. We will start with the installation of Docker then Docker Compose.

There are two editions of Docker available.

  • Community Edition (CE): ideal for individual developers and small teams looking to get started with Docker and experimenting with container-based apps.
  • Enterprise Edition (EE): Designed for enterprise development and IT teams who build, ship, and run business-critical applications in production at scale.

The Docker Enterprise Edition requires an active license to use. In this guide, we will install Docker CE on RHEL 8. Let’s add Docker repository before we can install it.

### CentOS 8 ###
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

### RHEL 8 ###
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo

This command will download Docker repository file to /etc/yum.repos.d/docker-ce.repo. Let’s update RPM index cache.

### CentOS 8 ###
$ sudo yum makecache 
CentOS Linux 8 - AppStream                                                                                                                                             23 kB/s | 4.3 kB     00:00
CentOS Linux 8 - BaseOS                                                                                                                                                20 kB/s | 3.9 kB     00:00
CentOS Linux 8 - Extras                                                                                                                                               9.2 kB/s | 1.5 kB     00:00
Docker CE Stable - x86_64                                                                                                                                             291 kB/s |  19 kB     00:00
DigitalOcean Droplet Agent                                                                                                                                             51 kB/s | 3.3 kB     00:00
Metadata cache created.

### RHEL 8 ###
$ sudo yum makecache 
Updating Subscription Management repositories.
Docker CE Stable - x86_64                                                                                                                                             14 kB/s | 3.8 kB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                                                                                                              33 kB/s | 2.8 kB     00:00    
Red Hat Ansible Engine 2.8 for RHEL 8 x86_64 (RPMs)                                                                                                                   29 kB/s | 2.4 kB     00:00    
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                                                                                                                 30 kB/s | 2.4 kB     00:00    
Red Hat Satellite Tools 6.6 for RHEL 8 x86_64 (RPMs)                                                                                                                  29 kB/s | 2.1 kB     00:00    
Metadata cache created.

You may need to uninstall all older versions of Docker along with associated dependencies. Also uninstall Podman and the associated dependencies if installed already.

sudo yum remove docker 

Finally install Docker CE by running the command below in your terminal.

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

If you get dependency issues with Podman allow errasing.

sudo yum install docker-ce --allowerasing

Agree to install by hitting the y key in your keyboard:

Transaction Summary
Install  12 Packages

Total download size: 93 M
Installed size: 389 M
Is this ok [y/N]: y

Import GPG key as well.

Total                                                                                                                                                            51 MB/s |  93 MB     00:01
Docker CE Stable - x86_64                                                                                                                                        44 kB/s | 1.6 kB     00:00
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y

Start and enable Docker Service to start at boot.

$ sudo systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

The docker service status should indicate running.

$ 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 2023-06-02 09:17:29 UTC; 3s ago
     Docs: https://docs.docker.com
 Main PID: 4631 (dockerd)
    Tasks: 8
   Memory: 26.8M
   CGroup: /system.slice/docker.service
           └─4631 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jun 02 09:17:28 rocky8.mylab.io systemd[1]: Starting Docker Application Container Engine...
Jun 02 09:17:28 rocky8.mylab.io dockerd[4631]: time="2023-06-02T09:17:28.761617345Z" level=info msg="Starting up"
Jun 02 09:17:28 rocky8.mylab.io dockerd[4631]: time="2023-06-02T09:17:28.812420399Z" level=info msg="Loading containers: start."
Jun 02 09:17:29 rocky8.mylab.io dockerd[4631]: time="2023-06-02T09:17:29.267431643Z" level=info msg="Loading containers: done."
Jun 02 09:17:29 rocky8.mylab.io dockerd[4631]: time="2023-06-02T09:17:29.294146578Z" level=info msg="Docker daemon" commit=659604f graphdriver=overlay2 version=24.0.2
Jun 02 09:17:29 rocky8.mylab.io dockerd[4631]: time="2023-06-02T09:17:29.294352733Z" level=info msg="Daemon has completed initialization"
Jun 02 09:17:29 rocky8.mylab.io dockerd[4631]: time="2023-06-02T09:17:29.355920339Z" level=info msg="API listen on /run/docker.sock"
Jun 02 09:17:29 rocky8.mylab.io systemd[1]: Started Docker Application Container Engine.

The docker group is created, but no users are added to the group. Add your user to this group to run docker commands without sudo

$ sudo usermod -aG docker $USER
$ newgrp docker
$ id $USER
uid=1000(jmutai) gid=1000(jmutai) groups=1000(jmutai),10(wheel),984(docker)

Logout and Login again to use Docker without sudo. The version of Docker installed can be checked with:

$ docker version
Client: Docker Engine - Community
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:53:10 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:52:10 2023
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
  Version:          0.19.0
  GitCommit:        de40ad0

Pull Test docker image

The last step is to test your installation by downloading a test docker container.

$ docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
8e402f1a9c57: Pull complete 
Digest: sha256:644fcb1a676b5165371437feaa922943aaf7afcfa8bfee4472f6860aad1ef2a0
Status: Downloaded newer image for alpine:latest

$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
Status: Downloaded newer image for hello-world:latest

List downloaded images.

$ docker images
 REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
 alpine              latest              5cb3aa00f899        2 days ago          5.53MB
 hello-world         latest              fce289e99eb9        2 months ago        1.84kB

Verify that Docker CE is working correctly by running the alpine container from downloaded image.

$ docker run -it --rm alpine /bin/sh
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
v3.15.4-87-g89e29fdace [http://dl-cdn.alpinelinux.org/alpine/v3.15/main]
v3.15.4-87-g89e29fdace [http://dl-cdn.alpinelinux.org/alpine/v3.15/community]
OK: 9754 distinct packages available
/ # exit

Hello world container run

$ docker run -it --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.
 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:

For more examples and ideas, visit:

Install Docker Compose on CentOS 8 | CentOS 8

We have Docker installed and running, let’s now change gear to Docker Compose. Docker Compose is a tool used to define and run multi-container Docker applications.

The application services are configured using a Compose file. Unlike running docker commands, a single command is all that’s required to create and start all the services from your configuration. Docker Compose is a great tool for development, testing, and staging environments, as well as CI workflows.

Follow our separate guide on installation of latest Docker Compose on Linux.

For the sake of keeping this guide brief, we won’t dive into Docker compose usage. I’ll recommend you go through Official Docker documentation and Docker Compose documentation to learn more.

Install Docker UI – Optional

If you need Docker management UI which allows you to easily manage your different Docker hosts and containers, please give Portainer a try. It is easy to install and use.

Monitoring Docker containers

Monitoring Docker containers can be achieved by using Monitoring tools such as Netdata or Ctop or Prometheus and Grafana. Below guides should be helpful.


Your Cart is Empty

Back To Shop