24.06.2025

How to Install Docker and Docker Compose on CentOS 8

Docker is a powerful platform for managing and running containers — lightweight, portable environments that package together everything needed to run an application, including the operating system, libraries, and dependencies. Within a Docker container, a minimal Linux distribution and all required software components are bundled into a self-contained unit. Once built, this container can be easily moved and executed on any system where Docker is installed, regardless of the underlying host OS. This ensures consistent behavior across development, testing, and production environments — one of the key reasons why Docker has become an essential tool for developers, system administrators, and DevOps engineers alike. Its portability, scalability, and efficiency have made it the go-to solution for modern software delivery workflows.

In the Serverspace you can create a server with already installed app "Docker".

In this step-by-step tutorial, we will walk through the process of installing Docker and Docker Compose on a CentOS 8 system. After the installation, we’ll also verify that everything is working correctly by running a test container to ensure your environment is ready for containerized applications.

Docker installation on CentOS 8

To install and always update Docker to the latest version, add the developer repository to the system.

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

Install the Docker package.

dnf install docker-ce docker-ce-cli containerd.io

Start the Docker service and add it to autorun.

systemctl enable --now docker

CentOS 8 uses a firewall other than Docker. Hence, if you have firewalld enabled, you need to add a masquerade rule to it.

firewall-cmd --zone=public --add-masquerade --permanent
firewall-cmd --reload

Docker compose installation

Docker is often installed along with Docker compose. It is this utility that allows you to deploy your project to another machine using one command. To download it, run the following command:

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

Make it executable.

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

Using Docker as a non-root user

To be able to use Docker as a non-root user, you must add that user to the docker group.

usermod -aG docker username

Replace the username with the desired user name. After executing this command, he will need to log out from the system and log in again.

Be careful! Users of this group can take control of the Docker host.

Docker test container running

You can verify that Docker is working properly by running a test container.

docker run hello-world

As a result of executing the command, you should see a message that everything is working well.

FAQ: Installing Docker and Docker Compose on CentOS 8