News
3 new Serverspace GPT API Language Models available now!
JH
Joe Harris
December 28 2020
Updated June 24 2025

How to Install Docker and Docker Compose on CentOS 8

CentOS Linux

Using another OS?

Select the desired version or distribution.

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

  • Q: What’s the difference between Docker and Docker Compose?
    A: Docker allows you to run individual containers, while Docker Compose lets you define and run multi-container applications using a single YAML file. It’s especially useful for managing complex setups with databases, backends, and frontends.
  • Q: Do I always need root access to use Docker?
    A: No, you can configure Docker to work without root by adding your user to the docker group. However, be cautious: users in this group effectively have root-level access to the system.
  • Q: Why do I need to enable masquerading in the firewall?
    A: On CentOS 8, Docker’s networking may not work correctly with firewalld unless IP masquerading is enabled. This allows Docker containers to access external networks.
  • Q: How do I check the Docker and Docker Compose versions?
    A: Run docker --version and docker-compose --version to verify installed versions and ensure everything was installed correctly.
  • Q: Is it safe to use the latest version of Docker from the developer repository?
    A: Yes, adding Docker’s official repository ensures you're installing the most stable and secure release directly from Docker Inc., with regular updates.
  • Q: Can I install Docker automatically on my virtual server?
    A: Yes! If you're using Serverspace, you can deploy a virtual server with Docker preinstalled via the control panel.
Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.