Anyway, this article is not about Podman. It’s about getting Docker installed on CentOS 8. If you really don’t want to switch to Podman and keep using Docker on your RHEL 8 or CentOS 8 machine, then this article is for you.
NOTE: If you’re going to use Docker on a production machine, then I recommend you not to upgrade to CentOS 8/RHEL 8. Keep using CentOS 7/RHEL 7 until Docker has official support for RHEL 8 and CentOS 8.
Installing Required Tools:
First, update the CentOS 8 package repository cache with the following command:
Now, install all the tools required for installing Docker CE with the following command:
fuse-overlayfs wget
To confirm the installation, press Y and then press <Enter>.
All the required tools should be installed.
Adding Docker CE Official Package Repository:
Docker CE is not available in the official package repository of CentOS 8. But you can add the official Docker CE package repository on CentOS 8 and install Docker from there.
To add the official Docker CE package repository, run the following command:
docker-ce.repo
Now, update the CentOS 8 package repository cache with the following command:
Installing Containerd.io:
The main incompatibility of Docker CE on RHEL 8 and CentOS 8 is containerd.io package. Docker CE depends on that package, but RHEL 8 and CentOS 8 officially flagged these packages. So, you can’t install the version of containerd.io package that Docker needs to work on RHEL 8 and CentOS 8 using the DNF or YUM package managers directly.
Luckily, we can manually download the latest version of containerd.io package and install it on CentOS 8.
First, navigate to the /tmp directory as follows:
The latest version of containerd.io package is 1.2.6-3.3 at the time of this writing. You may check for a later version when you’re reading this article at https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
Now, download the latest version of containerd.io package from the official CentOS 7 package repository of Docker CE with the following command:
containerd.io-1.2.6-3.3.el7.x86_64.rpm
The latest version of containerd.io package should be downloaded.
The containerd.io RPM package file should be in the /tmp directory as you can see in the screenshot below.
Now, install the containerd.io-1.2.6-3.3.el7.x86_64.rpm package file using DNF package manager as follows:
To confirm the installation, press Y and then press <Enter>.
The latest version of containerd.io should be installed.
Now, you’re ready to install Docker CE on your CentOS 8 machine.
Installing Docker CE:
To install Docker CE on CentOS 8 from the official Docker CE package repository, run the following command:
To confirm the installation, press Y and then press <Enter>.
The DNF package manager should start downloading all the required RPM packages from the Docker CE package repository. It may take a while to complete.
At this point Docker CE should be installed.
Now, check the status of the docker service with the following command:
The docker service may be inactive (not running) and disabled (won’t auto start on boot) as in my case.
To start the docker service, run the following command:
Also, to automatically start the docker service on system boot, add the docker service to the system startup of CentOS 8 as follows:
Now, check the status of the docker service again.
The docker service should be active (running) and enabled (will auto start on system boot).
You will not want to run Docker commands with sudo or as root user. In order to run Docker commands as your login user, you must add your login user to the docker group.
To add your login user to the docker group, run the following command:
Now, reboot your CentOS 8 machine with the following command:
Once your CentOS 8 machine boots, you can check whether Docker is working with the following command:
As you can see, I am running Docker CE 19.03.5. Docker Engine client and server is also working.
Now, let’s try to run the hello-world Docker container.
As you can see, Docker pulled the hello-world container from the internet and ran it successfully.
So, that’s how you install Docker CE on CentOS 8. Thanks for reading this article.