How to install docker on CentOS/Rocky/AlmaLinux
To install docker on Linux, you can follow the following simple steps. These steps have been tested on CentOS 7, Centos Stream 8 & 9, AlmaLinux 8 & 9, Rocky Linux 8 & 9.
- Update you system: make sure the system is up to date by running the following command:
# yum -y update
- Install the required dependencies: Docker requires a few dependencies. Install them by running the following command:
# yum install -y yum-utils device-mapper-persistent-data lvm2
- Setup Docker Repository: You can setup the official docker repository by running the following command:
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Install Docker: Once you have set up the official repository, you can now install docker. But first remove conflicting packages by running the following command:
# yum -y remove podman pdman-docker runc
Now install docker by running the following command:
# yum -y install docker-ce
- Start and Enable the docker service: Once you have set up the official repository, you can now install docker by running the following command:
# systemctl start docker
# systemctl enable docker - Verify the installation: To verify that Docker is installed and running correctly, you can run the following command: This command will download and run the hello-world Docker image, which will display a message to confirm that Docker is working properly.
# docker run hello-world