
Introduction
Docker is a powerful platform that enables developers to automate the deployment of applications inside lightweight, portable containers. This guide provides detailed instructions for installing Docker on CentOS, ensuring you have the latest setup for your development needs.
Pre-requisites
System Requirements
- Ensure you’re using a maintained version of CentOS. Docker supports CentOS 7 and newer releases. Please note that Red Hat no longer supports CentOS and it is now fully community driven. Currently ‘CentOS 9 (stream)’ is the supported OS.
- Ensure that user which will be used for installation and configuration of Docker has ‘sudo’ privileges.
- Check if centos-extras repository is enabled or not. If it disabled, then enable it.
Uninstallation of Old Versions
Uninstall any older version to avoid possible conflicts. This is because some distribution of Linux can provide unofficial version of docker. The below command can be used. Both yum and dnf can be used. Commands are provided for both.
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engineOR
sudo dnf remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engineNote: The images, containers, volumes and networks which are stored in
/var/lib/dockerare not removed automatically when Docker is uninstalled.
Installation
Refresh package index to ensure all repositories are up to date.
sudo yum update -y
Install necessary packages that allow yum to use repositories over HTTPS.
sudo yum install -y yum-utils
If using dnf, ensure dnf-plugins-core package is installed which provides the commands to manage dnf repositories. Also setup docker repository.
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
Set up the stable Docker repository.
sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install the latest version of Docker Engine, along with associated components.
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
OR
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and accept it.
Start the Docker service and configure it to start on boot.
sudo systemctl start docker
sudo systemctl enable –now docker
Confirm that Docker is installed correctly by running a test image.
sudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.
Post-Installation
To run Docker commands without sudo, create a Linux group called docker and add your user to it.
sudo groupadd docker
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
Conclusion
By following these steps, you’ve successfully installed Docker on your CentOS system. You can now leverage Docker to containerize your applications, enhancing portability and efficiency in your development workflow.
For more detailed information and advanced configurations, refer to the official Docker documentation.
Please watch the video for installation demo.

No responses yet