How to Install Docker on AlmaLinux / Rocky Linux

This article will guide you step-by-step through the most efficient way to install Docker on AlmaLinux 8 or Rocky Linux 8.

Docker is a popular open-source platform for developing, deploying, running, and shipping applications using containers. They are similar to virtual machines and aid in separating applications from the system.

It is now simple to create an application, package it with all of its dependencies inside a container, and deliver it anywhere.

If you’ve just installed AlmaLinux or Rocky Linux, you might be wondering how to get Docker up and running since RHEL doesn’t offer native support for Docker.

It probably seems strange to you and if you ask yourself, is there a reason for this, the answer is, yes, there is? Red Hat offers support for its product, Podman, an alternative to Docker.

So without further ado, let me show you how to install Docker on AlmaLinux or Rocky Linux and get started with installing containerized software. 

Step 1: Updating the System

Begin by updating the AlmaLinux / Rocky Linux 8 system OS packages to recent versions. This way, we ensure we have a wholly upgraded system.

So, first, please update existing software with the following command:

sudo dnf update
Update AlmaLinux / Rocky Linux 8 system

As you can see, there are no update packages available, but if you have updates, apply them before proceeding to the next step.

Step 2: Adding Docker Repository

There is a Docker repository for RHEL-based Linux systems that contains rpm packages for installation. So we’ll need to add this repository before installing Docker on AlmaLinux 8 / Rocky Linux 8.

First, type the following command in your terminal window to install the yum-utils package:

sudo dnf install yum-utils
Installing the yum-utils package

The yum-utils package provides a collection of tools for managing yum repositories.

Next, we need to add the Docker repository to our system with the following command:

sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoCode language: JavaScript (javascript)
Adding the Docker repo to AlmaLinux / Rocky Linux

As you can see, the system informs you that it has successfully retrieved the repository.

Step 3: Run System Update

Run the system update that will force your AlmaLinux / Rocky Linux distro to rebuild the system repo cache for the system to recognize the newly added Docker repository and the packages available in it.

sudo dnf update
Updating Docker repo

Step 4: List Available Repos

You can use this command to verify that the Docker repo was properly added:

sudo dnf repolist
List available repositories

Step 5: Install Docker on AlmaLinux / Rocky Linux

Now that we’ve added the Docker repository to our system, we can install Docker along with its command-line tool and containerd.io, to manage the container lifecycle of its host system more efficiently.

The command below will install the latest docker package for AlmaLinux / Rocky Linux:

sudo dnf install docker-ce docker-ce-cli containerd.ioCode language: CSS (css)
Install Docker on AlmaLinux / RockyLinux

Confirm with “Y” that you allow the installation of the displayed list of packages.

Next, you will be asked if you accept the Docker GPG key to be imported into your system. Confirm again with “Y.”

Importing the Docker GPG repo key into AlmaLinux / Rocky Linux

Wait for the confirmation message for the successful completion of the Docker installation on your AlmaLinux / Rocky Linux system.

Docker successfully installed on AlmaLinux / Rocky Linux

Step 6: Start, Enable, and Verify the Docker Service

After the installation is complete, you can launch the Docker service and configure it to start automatically when the system boots:

sudo systemctl start docker
sudo systemctl enable docker
Start the Docker systemd service

To confirm the running status of Docker, issue the command:

sudo systemctl status docker
Verifying the Docker service status

As you can see, Docker is up and running as expected.

Step 7: Enabling Non-root Users to Run Docker Commands

So far, we have successfully installed Docker on our AlmaLinux / Rocky Linux system.

However, only root and users with sudo privileges can execute Docker commands by default. So, if you attempt to run the docker command without prefixing it with sudo, you’ll get an output like this:

Docker without sudo - permission denied

To run Docker commands as a non-root user, you must add your user to the docker group. To do that, type in:

sudo usermod -aG docker ${USER}

In the command shown above, ${USER} is an environment variable that holds your username.

Now, you can check if your user is in docker group or not:

id $USERCode language: PHP (php)
Adding user to the docker group

You can log out and log back in to get the group membership session updated.

Step 8: Testing the Docker Installation

Now that we’ve installed Docker on AlmaLinux / Rocky Linux, it’s time to ensure everything is working correctly.

To do this, we’ll need a container image to test with. Fortunately, an image is already available for testing. Let’s put the installation to the test by running the hello-world container with the following commands:

docker pull hello-world
docker run hello-world
Testing Docker installation on AlmaLinux / Rocky Linux

Congratulations! You deserve it! This output confirms the installation of Docker on AlmaLinux / Rocky Linux was successful.

Conclusion

This tutorial demonstrated how to install Docker on AlmaLinux / Rocky Linux system. Now you can get started with pulling images and running containers.

To learn more about Docker, check out the official Docker documentation or take a look at our great introductory guide: What is a Docker Container: An Introductory Guide for Beginners.

Let me know if you have any questions or suggestions, and I’ll be happy to follow up with you. Happy dockering!

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%

Leave a Reply

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