This page looks best with JavaScript enabled

Install Docker on RHEL 8 or CentOS 8

 ·   ·  ☕ 4 min read

Attempting to install docker on Red Hat Enterprise Linux 8.6 did not work for me following the official instructions for install by repo on docs.docker.com1. So here are instructions that have worked for me as of this writing.

tldr: The x86_64 and arm64 architectures are not hosted on download.docker.com for rhel. But they are for CentOS, so use the CentOS repos instead.

Install Instructions

Steps:

This will add the upstream docker repo to DNF.

Next you install the docker components. Not all of these are needed necessarily, like docker-compose-plugin, but are nice to have to get a full featured installation. Obviously you can modify this list if you need a slimmer install.

Thirdly, we add the current user to the docker group. This may or may not be needed, but it allows you to run docker commands without sudo. Be aware! This is tantamount to granting your user root privileges as you will now be able to run privileged docker containers that can do anything that root can do (and without the same audit trial that sudo would give you). It might be worthwhile to add all docker commands to auditd for logging, but that's out of scope for this how-to. Omit this usermod command to be able to use docker safely (but less conveniently) using sudo docker instead. Also note that this change will not take effect until your next login, so you will still have to use sudo docker or logout/login or do some hack like newgrp docker to use docker as your current user.

Lastly, we enable the docker daemon and start it. This will make the daemon start everytime the computer starts (technically only when it enters multi-user mode), it also starts the daemon immediately due to the --now flag.

What happens when you follow upstream instuctions on RHEL 8?

  • sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
  • Updating Subscription Management repositories.
    Docker CE Stable - x86_64 628 B/s | 381 B 00:00
    Errors during downloading metadata for repository 'docker-ce-stable':

As of this writing https://download.docker.com/linux/rhel/8/x86_64/stable/repodata/repomd.xml does not exist, so we cannot install anything from that repo and we get the error: Error: Failed to download metadata for repo 'docker-ce-stable': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

Why don't the upstream instructions work?

The instructions on docs.docker.com1 for RHEL point you to use the https://download.docker.com/linux/rhel/docker-ce.repo repo. This repo points to to https://download.docker.com/linux/rhel/$releasever/$basearch/stable which on an x86_64 RHEL8 box resolves to a path that doesn't exist. Checking out where it points to, we can see why.

a screenshot of the docker repo contents at https://download.docker.com/linux/rhel/8 showing only two directories: 's390x' and 'source'

The only architectures they have builds for are s390x and source rpms. The same applies for RHEL7 and RHEL9. However, the CentOS repo offers builds for all of the common architectures.

a screenshot of the docker repo contents at https://download.docker.com/linux/centos/8 showing only many directories including 'x86_64'

Is it safe to use the CentOS RPMs on RHEL?

Almost certainly.

I'm still unsure what Docker is targeting with their "CentOS" builds. My first guess was CentOS Stream, because that's really the only CentOS that exists anymore. If these are builds targeting stream, then you may run into issues. However, the only issues that are likely to occur would be package install dependency issues, where you can't upgrade because it's depending on a package in CentOS Stream that's not yet in a RHEL stable release. I have trouble imagining an issue where a CentOS Stream package installs on RHEL without complaint, but breaks at runtime because of a difference between CentOS Stream and RHEL. Great pains are taken to ensure that the shared dependencies are the same between CentOS Stream and RHEL for a given package name.

However, I'm not particularly convinced that these are CentOS stream builds. They have builds going back to CentOS 7 builds before Stream was introduced, which means at least some of these are not CentOS stream. Also, in my (admittedly anecdotal) experience, Rocky Linux and Alma Linux installs are outnumbering the CentOS Stream installs in production (I won't weigh in on whether that's good or bad). So I believe that these are probably builds that are targeting one of those, but using the CentOS name because it has the brand recognition.

All that said, I don't know. All I know is what every good developer knows: It worked on my machine.

Share on

Topher
WRITTEN BY
Topher
System Administrator