
Steps to install Docker on CentOS 7
Step 1: Update Your System
First, it’s always a good idea to update your package database and upgrade all your system software to the latest version available. You can do this by running the following commands:
sudo yum update -y
Step 2: Install Required Packages
These packages are required for Docker to manage the underlying storage and devices on your CentOS system.
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Step 3: Set Up the Docker Repository
After installing the required packages, you need to add the Docker repository to your system. This enables you to install and update Docker from the repository provided by Docker Inc.
Execute the following command to add the Docker CE (Community Edition) repository:
sudo yum-config-manager — add-repo https://download.docker.com/linux/centos/docker-ce.repo
Step 4 : Install Docker CE
With the Docker repository in place, you can now install Docker CE on your CentOS 7 system. Run the following command:
This command installs the Docker engine (community edition), the Docker CLI client, and containerd, a container runtime.
sudo yum install docker-ce docker-ce-cli containerd.io -y
Step 5: Start and Enable Docker Service
Once the installation is complete, you need to start the Docker service and enable it to start at boot:
These commands ensure that Docker runs and starts automatically upon system boot.
sudo systemctl start docker
sudo systemctl enable docker
Step 6: Verify Docker Installation
To verify that Docker is installed correctly and is running, use the following command:
This command downloads a test image and runs it in a container. If everything is set up correctly, it will print a message indicating that your Docker installation is working.
sudo docker run hello-world
Step 7: Running Docker Commands Without Sudo (Optional)
By default, Docker requires sudo privileges to run. If you want to run Docker commands without sudo, add your user to the Docker group:
For this change to take effect, you need to log out and log back in, or you can type newgrp docker in the terminal.
sudo usermod -aG docker ${USER}
Step 8: Updating Docker
To update Docker in the future, simply run the standard yum update commands:
If there are any updates for Docker, they will be applied along with updates for other system software.
sudo yum update -y
Conclusion
Congratulations! You have successfully installed Docker on your CentOS 7 server. You’re now ready to begin containerizing your applications, ensuring they are portable and easy to deploy across any environment that runs Docker.
Share this article
Loading comments...
© 2026 CloudHouse Technologies Pvt.Ltd. All rights reserved.