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. Gunnar Thielebein

    This guide is incorrect for Centos8.
    The official docker repositories only ship Centos-7 packages for docker-ce.

    Installing docker-ce within Centos-8 fails with an error message:

    sudo -E dnf install docker-ce
    Last metadata expiration check: 0:02:14 ago on Wed 29 Jan 2020 06:13:57 AM EST.
    Error:
    Problem: package docker-ce-3:19.03.5-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
    – cannot install the best candidate for the job
    – package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
    – package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
    – package containerd.io-1.2.2-3.el7.x86_64 is excluded
    – package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
    – package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
    – package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
    (try to add ‘–skip-broken’ to skip uninstallable packages or ‘–nobest’ to use not only best candidate packages)

  2. Hi Gunnar,

    After configuring the Docker CE repository , run the following to install docker-ce package

    # dnf install docker-ce –nobest -y

  3. Hi Pradeep, I discovered what was the Gunnar’s problem, first you must remove podman from the system with
    sudo yum remove podman
    Then it will work fine!

    Regards

  4. Thank you Marcos! That was my problem. The instructions in this article worked like a charm after removing podman.

  5. Gunnar Thielebein

    Update from my site. I get docker installation suceeded in centos8 after removing podman, like it was suggested.
    Thanks anyone for the tips.

    To get docker compose (e.g. awx) running with external access to the website it was neccessary to enable NAT on the firewall level. This was suggested from Michael Kofler in his german Blog [1].

    firewall-cmd –zone=public –add-masquerade –permanent
    firewall-cmd –reload

    ‘https://kofler.info/docker-unter-centos-8-und-fedora-31-installieren/’

  6. When trying to run `sudo docker run hello-world` the system returns:
    docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused “process_linux.go:449: container init caused \”write /proc/self/attr/keycreate: permission denied\””: unknown.
    ERRO[0000] error waiting for container: context canceled
    What went wrong here?

  7. Vardhaman Kothari

    After installing Docker compose if it shows bash: docker-compose: command not found…
    You need to create a symbolic link /usr/bin or any other directory in your path.
    Try this:
    sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

    And then it works

Leave a Comment

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