1. Update your system:
sudo yum update
2. Install required dependencies:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3. Add the Docker repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4. Install Docker CE (Community Edition):
sudo yum install docker-ce docker-ce-cli containerd.io
5. Start the Docker service:
sudo systemctl start docker
6. Enable Docker to start on boot:
sudo systemctl enable docker
7. Verify that Docker is installed and running:
sudo docker --version sudo docker info
8. Manage Docker without sudo (optional): If you don’t want to use sudo
every time you run Docker commands, add your user to the docker
group:
sudo usermod -aG docker $USER
You’ll need to log out and log back in for the changes to take effect.
9. Test Docker with a simple container:
docker run hello-world
This command downloads a small test image and runs a container based on it. If everything is set up correctly, you’ll see a “Hello from Docker!” message.
That’s it! Docker is now installed and configured on your CentOS 7 system. You can start using Docker to run and manage containers.