How to Install Docker on RHEL 8 | Rocky Linux 8

In this guide, we will show you how to install docker on RHEL 8 and Rocky Linux 8.

Docker is a daemon-based container engine which allows us to deploy applications inside containers. With the release of RHEL 8 and Rocky Linux 8, docker package has been removed from their default package repositories, docker has been replaced with podman and buildah.

Docker is available in two versions,

  • Docker CE (Community Edition)
  • Enterprise Edition (EE)

In this guide, we will install docker community edition using yum command.

System Requirements for Docker

  • Minimal Install RHEL 8 or Rocky Linux 8
  • Sudo or root privileges
  • Internet Connection

Installing Docker on RHEL 8 | Rocky Linux 8

Without any further delay, let’s jump into the steps. Login to your RHEL or Rocky Linux system and follow beneath steps.

1) Remove Podman and Buildah

As podman and buildah packages are not required for Docker so remove them by running following command.

$ sudo yum remove podman buildah -y

2) Add Docker Repository

Docker rpm package is not available in the default package repositories of RHEL 8 and Rocky Linux 8. So, for its installation via yum command first we need to add its yum repository using following commands.

// For RHEL 8

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

Add Docker Repository on RHEL 8

// For Rocky Linux 8

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

3) Install Docker on RHEL 8 | Rocky Linux 8

Once the docker repository has been configured successfully then run following command to install latest version of docker and docker compose.

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

Install Docker on RHEL 8

After the successful installation of docker, start and enable its service using the following systemctl commands

$ sudo systemctl start docker
$ sudo systemctl enable docker

Run the following command to verify installed docker version

$ docker --version
Docker version 27.0.3, build 7d4bcd8
$ docker compose version
Docker Compose version v2.28.1
$

4) Add Local User to Docker Group

Add your local user to docker group so that it can run the docker commands with sudo. Run following commands:

$ sudo usermod -aG docker $USER
$ newgrp docker
$ id

Add Local User To Docker Group RHEL 8

5) Test Docker Installation

In order to test docker installation, try to run a container using hello-world image, run

$ docker run hello-world

Output of above command

Docker Run Hello-World Image RHEL 8

Informational message in above output confirms that docker engine is setup correctly on RHEL 8 or Rocky Linux 8.

Remove Docker

If you want to remove docker from your RHEL or Rocky Linux then run following commands,

$ sudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd

That’s all from this guide, I hope these steps help you to install docker and docker compose. Kindly do share your queries and feedback in below comments section.

Read Also: How to Use Docker Compose to Launch Multi-Container Application

24 thoughts on “How to Install Docker on RHEL 8 | Rocky Linux 8”

  1. @Pradeep Kumar containerd update from external repos is blocked by CentOS8. Workaround for now seems to be to install the CentOS7 version. If you don’t install it, you get the error you mentioned every time you try dnf update. –nobest is the enemy here.

    rpm -Uvh ‘https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm’

  2. I am getting below error for RHEL 8.2:
    Docker version 19.03.9, build 9d988398e7
    [root@control ~]# docker version
    Client: Docker Engine – Community
    Version: 19.03.9
    API version: 1.40
    Go version: go1.13.10
    Git commit: 9d988398e7
    Built: Fri May 15 00:25:27 2020
    OS/Arch: linux/amd64
    Experimental: false
    Error response from daemon: client version 1.40 is too new. Maximum supported API version is 1.39
    [root@control ~]#

  3. @n jaywan

    upgrade to latest

    curl -L “https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose
    docker-compose –version

  4. Solutions Architect

    Hi Pradeep,

    I found you blog very useful, I was setting up docker on my RED HAT Enterprise edition and this blog simplified installation process.

    Thanks for posting it.

    Regards,
    Farooq

  5. If you disable CentOS’ container-tools module you can install the latest Docker CE using docker-ce.repo, that is no more –nobest necessary:

    dnf module disable container-tools
    dnf install docker-ce docker-ce-selinux

  6. you have to add on last step to be able to check the command “docker-compose –version” :

    ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

  7. Hi there,
    Thanks for the great post! Is this solutions still valid? because I keep getting error running the first command. Please advice

    [osboxes@osboxes tmp]$ sudo dnf update -y ; reboot
    created by dnf config-manager from ‘https://download.docker.com/li’ 926 B/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for ‘https://download.docker.com/linux/centos/repodata/repomd.xml’ (IP: 99.86.61.24)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
    Failed to set wall message, ignoring: Interactive authentication required.
    Failed to reboot system via logind: Interactive authentication required.
    Failed to open initctl fifo: Permission denied
    Failed to talk to init daemon.
    [osboxes@osboxes tmp]$

    [osboxes@osboxes ~]$ sudo dnf update -y
    [sudo] password for osboxes:
    created by dnf config-manager from ‘https://download.docker.com/li’ 1.3 kB/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for ‘https://download.docker.com/linux/centos/repodata/repomd.xml’ (IP: 99.86.61.58)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
    [osboxes@osboxes ~]$ sudo dnf config-manager –add-repo=’https://download.docker.com/linux/centos/docker-ce.repo’
    Adding repo from: ‘https://download.docker.com/linux/centos/docker-ce.repo’
    [osboxes@osboxes ~]$ sudo dnf list docker-ce
    Docker CE Stable – x86_64 36 kB/s | 3.5 kB 00:00
    created by dnf config-manager from ‘https://download.docker.com/li’ 1.2 kB/s | 367 B 00:00
    Errors during downloading metadata for repository ‘download.docker.com_linux_centos_’:
    – Status code: 404 for ‘https://download.docker.com/linux/centos/repodata/repomd.xml’ (IP: 99.86.61.79)
    Error: Failed to download metadata for repo ‘download.docker.com_linux_centos_’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

    1. Hello Ibrahim,

      Above steps are still valid for CentOS 8 & RHEL 8. I have tested on CentOS 8 system, it is working as expected. I would suggest first remove the docker repository that you have configured and also remove podman and docker ( older version) in case it is installed.

      Update the system and then try these steps.

    2. use above in article to create repo and use below cmd to install
      #dnf install docker-* -y –nobest –allowerasing

Leave a Comment

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