Installing Docker Engine on CentOS

Reading Time: 2 minutes

Installing Docker Engine on CentOS is an article that shows how to install the Docker container application on Linux CentOS.

First and foremost, we have written an article explaining installing CentOS Linux. You can read this article by accessing the following link:
https://www.dpcvirtualtips.com/installing-linux-centos-7/

Note: We are using CentOS 7 in this case!

  1. Firstly, we need to make some adjustments to the CentOS repositories. Edit the file “/etc/yum.repos.d/CentOS-Base.repo” and uncomment each line starting with “#base”:
cat /etc/yum.repos.d/CentOS-Base.repo | grep -i "#base"

This step is necessary to make the CentOS repositories reachable. Additionally, we need to disable the IPv6 protocol:

sysctl -w net.ipv6.conf.all.disable_ipv6=1

2. Set up Docker’s repository:

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Note: If you receive an error after executing the second command (yum-config-manager), enable the IPv6 support again, reboot your system, and try this step again. To enable the IPv6 support:

sysctl -w net.ipv6.conf.all.disable_ipv6=0

3. Install Docker Engine. In this case, for instance, we are installing the latest Docker version available at the moment:

yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

4. Start the Docker daemon (if the Docker daemon is not running, you can enable and start it by using the following command):

systemctl enable docker
systemctl start docker

5. Verify that the Docker Engine installation is successful by running the “hello-world” image. We will create a container based on this image just to check the Docker Engine:

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. You have now successfully installed and started Docker Engine:

6. We can run the command “docker info” just to check the details of the docker version installed on our system:

docker info

Source: https://docs.docker.com/engine/install/centos/