Install Docker on RHEL 8

This article shows you how to install Docker community edition on RHEL 8 Server

Add docker ce repo to repo manager

# Add to repo mananger
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

# Verify your change
sudo dnf repolist -v

Choose specific version to install

# List available version
dnf list docker-ce --showduplicates | sort -r
# Example output
docker-ce.x86_64                3:23.0.1-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:20.10.9-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.8-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.7-3.el8                 docker-ce-stable
...

# Choose latest stable version to install
sudo dnf install docker-ce-3:23.0.1-1.el8
OR
sudo dnf install docker-ce --nobest

# If there're still errors when trying above commands, like container.io conflicts
# Try to install container.io manually
sudo dnf install containerd.io --allowerasing
# Install docker ce 
sudo dnf install docker-ce
# Start docker and test
sudo systemctl start docker
sudo docker run hello-world

Manage docker as non root user

# Create the docker group.
sudo groupadd docker

# Add current logged in user to docker group
sudo usermod -aG docker $USER

# If you have a dedicated agent to run docker command, eg. Jenkins, add jenkins user to docker group
sudo usermod -aG docker jenkins

# Active changes to group
newgrp docker 

# Verify docker can run without sudo
docker run hello-world
# Example output
[user@rhel8 ~]$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Run docker when system start (as a servcie)

sudo systemctl enable docker.service
sudo systemctl enable containerd.service
Scroll to Top