The new CentOS 8 release has introduced many innovative elements compared to its predecessor. Our recent article provides an in-depth analysis of the new and improved features of CentOS 8.
One significant change is the decision to no longer provide official support for Docker. Instead, RHE has opted to introduce in-built tools for container image creation and management: buildah and podman. These tools are compatible with Docker but don’t need a server/client architecture to run.
In case you are still not ready to use these new tools just yet, this tutorial will explain how to install Docker on CentOS 8.
Important: Disabling critical security features is not encouraged. However, the firewalld manager in CentOS 8 prevents DNS resolution within Docker containers. This tutorial contains instructions on how to disable firewalld.
Add Docker Repository Using DNF
CentOS 8 uses the YUM package manager version v4.0.4. This version now uses DNF (Dandified YUM).
DNF is a software package manager. It installs, performs updates, and removes packages on Linux distributions.
Note: CentOS 8 has a much-improved software management system. DNF technology provides increased performance, has well-defined APIs, and supports modular content, software AppStreams for cloud, container workloads, and CI/CD.
Use DNF to add and enable the official Docker CE repository. Type the following command in your terminal window:
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
The system informs you that it has successfully retrieved the repository.
sudo dnf repolist -v
The onscreen information provides all relevant details.
To list all the available docker-ce packages, type:
dnf list docker-ce --showduplicates | sort -r
Unfortunately, CentOS 8 does not support specific versions of the container.id package. This means that only some versions of docker-ce are available for installation.
There are two ways to address this issue and install Docker on CentOS 8.
Install Docker CE on CentOS 8
Option 1: Skip Packages with Broken Dependencies
An efficient solution is to allow your CentOS 8 system to install the version that meets the criteria best, using the
sudo dnf install docker-ce --nobest
The installation skips the latest candidates and installs the most appropriate version with the required containerd.io packages.
Once you confirm by entering y, the system proceeds to install Docker CE 18.06.3.ce-3.el7.
If you look closely, you will see that the installation skipped the latest version of docker-ce as it did not meet the criteria.
Option 2: Install containerd.io Package Manually
Another option for installing Docker on CenOS 8 is to install the containerd.io package manually, in advance. This workaround allows you to install the latest docker-ce version.
Use the following command:
sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm
Confirm the installation with y. You have successfully installed the latest version of containerd.io.
Now we can proceed to install the latest version of docker-ce with a simple command:
sudo dnf install docker-ce -y
The output below confirms that docker-ce-3:19.03.5-3.el7.x86_64 has been successfully installed.
Start and Test Docker
Enable and start the Docker service with:
sudo systemctl enable --now docker
The output confirms that we have created a symlink.
Next, use this short command to confirm that Docker is active and running:
systemctl status docker
We see the timestamp and confirm that Docker is active.
Add User to Docker User Group
Add your user to the docker group with the following command:
sudo usermod -aG docker $USER
The system executes the commands.
Disable firewalld on CentOS 8
As mentioned previously, we need to disable firewalld for DNS resolution inside Docker containers to work.
One simple command is enough to disable firewalld in CentOS 8:
sudo systemctl disable firewalld
The output confirms that the service has been disabled.
At this point, it is recommended to reboot your system for the change to take effect.
Testing Docker Installation by Pulling Test Container Image
Download a small alpine docker container image to test the installation:
docker pull alpine
The system downloads the latest version of the image.
Check if the image is available:
The system lists your Docker images:
Initiate Alpine Container Image
Use Docker to run the container with the downloaded image and try doing a simple
docker run -it --rm alpine /bin/sh
/# apk update
The output confirms that the container has been initiated.
You have successfully installed and configured Docker on CentOS 8.
By following this tutorial, you should now have a working Docker installation on CentOS 8.
The release of CentOS 8 includes many new features that raise the bar for RHEL-based operating systems and improves overall UX.