Installing Docker on CentOS 8

Installing Docker & Docker Compose on CentOS 7/RHEL 7 is quite straight forward, but this process is quite tricky in CentOS8/RHEL8. This is because of the fact that Docker is not officially supported on CentOS8/RHEL 8 as it has been replaced with Red Hat tools – buildah and podman. In this post we will go through the process of installing Docker Community Edition in CentOS 8 with minimal installation.

Update your system

Install required packages

If this is the first time you install Docker on the machine, you will need to install the packages needed by Docker to run and set up the Docker repository.

Output

Set up Docker stable repository

Install Docker Engine – Community

Install specific version of Docker CE

As of now, Docker is not officially supported on CentOS/RHEL 8 because it has been replaced with Red Hat tools – buildah and podman. So if you try to install the latest version of Docker Community Edition, it will fail. What you can do is to check first which specific version of Docker is available for installation in your system, then go ahead with the actual installation. To find this out, issue below command:

Output

All versions mentionned in above output are available to be installed. We will take one version randomly. Let’s say 3:18.09.1-3.el7. To install this version, parse “docker-ce:” before it, so the full version to install would be as below:

docker-ce-3:18.09.1-3.el7

Hence, the command to install this version will be:

Output

Install the latest version of Docker CE

Above method will install a specific version of Docker, but If you still want to install the latest version of Docker CE anyway, you can use the dnf command with the –nobest option to to use not only best candidate packages if the latest version installation does not work.

Output

Start and enable Docker

Docker is installed but is still not started. Let’s start and enable it.

Verify Docker CE installation

Run an alpine test container to check your Docker Engine CE installation

Add users to Docker group

We have installed and started Docker successfully. However, for any command that you need run in Docker, you will have to use your root privileges. In other words, you will need to use sudo to run Docker commands. This is because after Docker is installed, a new group called docker is created, which is the only object that has the privilege to run Docker commands.

Because no user is added to the group by default, you will have to explicitly make your user a member of this group If you want to use Docker as a non-root user.

Update docker group membership

Run docker commands without sudo

Remove Docker

If you’re done with your testing and want to remove docker binaries, use below command

This will remove docker from tour system but will not get rid of all images, containers, volumes, or customized configuration files created before. To do so, use below command

 

Find this post interesting. Share it!

Leave a Comment

Your email address will not be published. Required fields are marked *