Docker is a container-based software that allows multiple applications to run inside the containers. This is a virtualization platform that is useful for developers and other users to feel fewer compatibility issues with an operating system. In Docker, various containers can communicate with each other and share the same kernel. So, you can run different applications in multiple containers. Docker can be installed on almost on all major distributions such as Windows, Linux (RHEL based distros, Debian based distros, etc.), Mac OS.
In this article we’ll explore how you can install Docker on a RHEL 8 distribution, such as AlmaLinux 8 or Rocky Linux 8, using the command-line. In our example we’ll be using AlmaLinux 8.
Table of Contents
Objectives
The main objective of this tutorial is to demonstrate how to install Docker on RHEL 8. After installing, how you can verify either Docker is installed on your system or not. So, we will provide the command through which you easily verify the Docker installation. We will learn about different Linux commands, to enable, start, and get the status of the Docker service. Furthermore, we will learn how to search for Docker images from the docker hub. At the end of this tutorial, you will be able to pull and run the docker container image on your RHEL 8.
Prerequisites
- RHEL 8 distribution should be running on your system.
- Non-root users should have sudo privileges.
- 15 GB or enough disk space is required to run the Docker containers.
Installation of Docker Container on RHEL 8
In the RHEL 8 system, docker container packages are not included by default, so you can’t install docker using the ‘dnf install’ command. First, you will need to include the Docker repository in your system and then remove the conflicting dependencies or packages that are installed by default on the RHEL distribution.
Let’s implement! The following steps will help you to install the docker container on RHEL 8 distribution:
Step 1: Add Docker Repository in RHEL 8
Here, we are including the docker repository in the RHEL distribution that is made for the CentOS system. Add the official docker repository on your RHEL 8 distribution. So, you don’t need to download docker packages manually on your system. Before adding the docker repository, install the following yum-utils that give you the yum configuration manager command-line tool.
sudo dnf update
sudo dnf install -y yum-utils
Now, add the Docker repository to your system by using the following command:
sudo yum config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
Once the Docker repository is added to your RHEL distro, you can install the docker without downloading its packages manually which is much more time-consuming.
Step 2: Update System Repositories
Update the system repositories for the changes to take effect. Use the following command to allow your RHEL distribution to rebuild the system repositories cache.
sudo yum update
To confirm whether the docker repository has been added to your RHEL system, run the following command:
sudo dnf repolist
Step 3: Remove Conflicting Packages
Before starting the Docker installation, you need to remove the conflicting packages, such as the “podman” and “buildah” packages, from your system. These packages conflict with Docker during the installation and prevent it from being installed on your RHEL 8 distribution. Use the following command to uninstall conflicting packages:
sudo dnf remove podman buildah
Step 4: Install Docker on RHEL 8
Finally, at this point you will install the docker packages on your system by running the following command:
sudo dnf install docker-ce docker-ce-cli containerd.io
Step 5: Enable Docker Service
Once the installation of Docker is completed, enable the Docker service and start it on your system by running the following commands:
sudo systemctl start docker.service
sudo systemctl enable docker.service
Now, the docker service will automatically start with the system boot.
After enabling the Docker service, view the running status to verify that Docker is working properly on your system.
sudo systemctl status docker.service
Step 6: Check Docker Version
Once Docker is installed, you can easily check the installed Docker version by executing the following command:
sudo docker version
One more quick method is given to check details about Docker’s configuration and the Docker containers that are currently running on your system.
sudo docker info
Step 7: Add non-root User to Docker group
If you don’t want to use “sudo” to run a Docker command on your system, you need to add the no-root user of your system to the Docker group. In this way, you can run the docker command as a non-root or current user. This is an optional step.
sudo usermod -aG docker $USER
After adding a non-root user to the docker group, reboot your system for the changes to take effect on your system.
reboot
Step 8: Test Docker
To test Docker, pull the hello world packages on your system by running the following command.
docker pull hello-world
The above output shows that docker has downloaded the ‘hello-world’ image successfully.
Once the ‘hello-world’ image is downloaded, now run this image by executing the following command:
docker run hello-world
This output verifies that Docker is working properly on your system.
After installing Docker on your system, you can build containerized applications using Docker and some other helpful tools.
Conclusion
We have performed the installation of Docker CE in this article. We demonstrated how to install Docker on a RHEL 8 distribution. Moreover, how to test the working of Docker on a Linux system via terminal. To get more help about Docker usage, visit the official Docker documentation. Thanks!
If you get a bunch of errors about containerd.io conflicting with runc when you use ‘sudo dnf update’, you’ll need to ‘sudo dnf remove runc’, ‘sudo dnf clean all’, and then ‘sudo dnf update’ before you attempt to install docker.
First of all, great guide! The commands on the official docker page don’t work for rhel 8.6 :(, because they use the rhel repo and that doesn’t have an installation candidate for rhel 8.6.
However, there are a few issues that should be corrected:
In a few places you put a different (and sometimes incorrect) command into the text field, but the screenshot contains the correct command. Please fix the following.
should be:
for consistency’s sake
should be:
Other than that, it seems to be okay.
Hi Andras! Glad the tutorial was useful to you!
You’re absolutely right – I apologize for the inconsistencies and have fixed them now. Thank you very much for your detailed feedback. It’s very much appreciated!
Also the is an issue with docker login. When I try to get hello-world it asks for a docker login. Even if I entered the login correctly and stored my password correctly it still fails to get the container giving the same error.