How to Install and Configure Docker & Docker Compose on CentOS 8

Docker is a daemon-based container engine technology which allows us to deploy applications inside containers. With RHEL 8 and CentOS 8, docker package has been replaced with podman and buildah. Docker can be compiled source code present on GitHub on the local system itself. Also, there are pre-compiled packages for Docker. It can be installed on the Host Machine OS or on a Virtual Machines. In this guide, we will see How to Install and Configure Docker & Docker Compose on CentOS 8 or RHEL 8.

Docker comes in two versions,

  • Docker CE (Community Edition)
  • Enterprise Edition (EE)

Prerequisite

  • Disable the SELinux and FirewallD services.
  • Linux Machine CentOS/RHEL 8 Installed in it.

Enabling Docker-ce Repository

Docker packages are not available by default anymore with CentOS/RHEL 8, so run following dnf command to enable Docker CE package repository.

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

Installing Docker-ce with dnf command

When the docker-ce repo has been configured successfully then run below command to verify which version of docker is available to install in centos 8 machine.

# dnf list docker-ce

Next run below dnf command to install latest version of docker ce, and press y to install

# dnf install docker-ce --nobest -y

You may get following error while installing docker on centos/rhel 8.

error while installing docker on centos 8

This error occured due to default podman and buildah packages. You have to remove both packages first to resolve this conflict.

 # dnf erase podman buildah

As you removed podman and buildah packages from your server, now try to install docker on your centos 8 machine.

# dnf install docker-ce --nobest -y

After the installing docker, you should start and enable its service using the below commands,

# systemctl start docker

# systemctl enable docker

You can check the running status of docker service as follows,

# systemctl status docker

running status of docker

Run the below command to verify installed docker version

# docker --version

Docker version 19.03.13, build 4484c46d9d

verify and test docker-ce Engine

To verify whether docker-ce engine has been installed correctly or not, try to spin up a “hello-world” container using below command,

# docker run hello-world

docker run hello-world

Installing Docker Compose on CentOS 8

Docker compose can be used to link multiple containers with a single command. Docker compose is useful where you need to launch multiple containers and these containers depends on each other. Run the below commands to install docker compose on CentOS 8 / RHEL 8,

# curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

You can replace “1.27.4” with desired docker compose version that you want to install.

Next set the executable permission to docker-compose binary,

# chmod +x /usr/local/bin/docker-compose

Verify the docker compose version by executing the following command.

# docker-compose --version

docker-compose version 1.27.4, build 40524192

docker compose version

Conclusion

In this guide, we saw how to Install and Configure Docker & Docker Compose on CentOS 8 or RHEL 8. I hope you can setup docker and docker compose on CentOS 8 and RHEL 8 server now. Please feel free to share your feedback and comments in the comments section.

Read Also : configure Networking and Port Mapping in Docker

Read Also : How to configure Docker Volumes

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

Leave a Comment