Docker is a powerful containerization platform that simplifies application deployment by packaging software and its dependencies into isolated environments. In this step-by-step guide, you’ll learn how to install Docker and Docker Compose on CentOS or RHEL systems easily and correctly.
This guide is tested on CentOS 8 and RHEL 8, but should work similarly on most recent versions.

🔄 Step 1: Update System Packages
Before installing Docker, it’s essential to make sure your system is fully updated. Use the following command to update all system packages:
sudo dnf update -y
Updating helps avoid compatibility issues and ensures the latest security patches are applied.
Step 2: Add Docker’s Official Repository
By default, Docker is not included in CentOS or RHEL repositories. You’ll need to add Docker’s official repository to your system using:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
This repository contains the most stable and up-to-date Docker packages maintained by Docker Inc.
Step 3: Install Docker Engine and Docker Compose
Now, install Docker Engine, Docker CLI, containerd, and the Docker Compose plugin by running:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
This command will install everything needed to run Docker containers and manage multi-container applications with Docker Compose.
Step 4: Start and Enable Docker
After installation, start the Docker service and enable it to launch at boot:
sudo systemctl start docker
sudo systemctl enable docker
You can confirm that Docker is running by checking its version:
docker --version
You should see an output like Docker version 25.0.3, build abc123
.
Step 5: Add Current User to Docker Group (Optional)
To run Docker without using sudo
, add your user to the docker
group:
sudo usermod -aG docker $USER
After running this command, log out and log back in for the changes to take effect.
Alternatively, if you don’t want to log out, run:
newgrp docker
This gives your current session access to the updated group settings.
Step 6: Verify Docker and Docker Compose Installation
Now that Docker is installed, test it by running the official “Hello World” container:
docker run hello-world
You should see a message confirming that Docker is installed and working correctly.
To verify Docker Compose installation:
docker compose version
If everything is set up properly, you’ll see the Docker Compose version displayed.
📚 Additional Resources
📝 Final Notes
- Docker Compose v2 is now included as a plugin with Docker Desktop and Linux CLI.
- Always use the latest version of Docker for performance and security improvements.
- Remember to regularly update Docker using
dnf update
to stay current.
By following the above steps, you’ve successfully installed Docker and Docker Compose on your CentOS/RHEL system. You’re now ready to start building and running containerized applications!