How to Install and Use Docker on AlmaLinux 8

Docker is a powerful platform for developers and sysadmins that simplifies the process of deploying applications inside software containers. Containers allow you to package up an application with all its parts (code, runtime, system tools, system libraries – anything that would usually go in /usr/bin, or /usr/lib) so it will run consistently on any Linux machine. This includes the operating system kernel and other shared resources such as memory and disk space. Docker provides a portable environment for both development and production environments. You can create a container from one set of files that works anywhere else without having to worry about dependencies being different on each new server.

Docker CE is useful for Linux users because it helps them in creating their own environments without affecting other users on the system. It also automates deployment, which eliminates configuration errors and makes it easy to manage projects across teams of developers who are working together on software applications.

In this guide, we will take a look at how we can install Docker CE to create and manage development environments on an AlmaLinux 8 system.


In order for this article to be of use, you will need the following:

  • A running AlmaLinux 8 system.
  • 15GB minimum of free disk space. One or more vCPUs at your disposal per each Docker container that you want to spin up.
  • A non-root user with sudo privileges.

Step 1: Updating the System

There are security updates that help protect your system from malware and other attacks on your computer. There are also kernel updates, which add new features or improve performance for hardware devices such as video cards and USB controllers.

These can be installed through the dnf update command on AlmaLinux 8.

sudo dnf -y update

Step 2: Adding Docker CE Repository

For Red Hat-based Linux systems, there is an open Docker CE repository that contains rpm packages for installation. Before we can install Docker CE on AlmaLinux 8, we’ll need to add this repository.

To add a Docker CE repository to your Rocky Linux 8 system, execute the command listed below.

sudo dnf install -y yum-utils
sudo yum-config-manager --add-repo

To confirm that the repository has been added properly, you can run this command.

sudo dnf repolist

Add Docker repository

Step 3: Installing Docker CE

Now that we’ve added the repository, we can use it to install Docker CE.

sudo dnf -y update
sudo dnf -y install docker-ce docker-ce-cli

This command will install the latest docker package for AlmaLinux 8. It installs Docker CE, which includes Docker, container, and command-line tools.

Install Docker CE

Once the installation has finished, you can start Docker CE with this command.

sudo systemctl start docker

You can check whether the service has started successfully by running this command.

sudo systemctl status docker

You should see the following output, which means that all is well.

Check status of Docker Daemon

If you want Docker CE to start automatically when AlmaLinux 8 boots up, run this command.

sudo systemctl enable docker

Step 4: Adding a Non-root User To Docker Group

Docker CE uses virtualization and needs to run as a privileged user. It is important that Docker only be accessible by the root user. To set this up on AlmaLinux 8, we need to add new non-root users to the Docker group. If not, you may not be able to access virtualization facilities and encounter the permission denied error. To add a new non-root user to the Docker group, we need to execute the following command.

sudo usermod -aG docker $USER

Where: $USER is your non-root user username. In this example, let’s add a user called vitux.

After running this command, log out and log back into your system. This will ensure that the changes are applied properly.

At this point, you can verify if the non-root user is a member of the Docker group by running this command.

id vitux

Step 5: Testing the Docker CE Installation

Now that we have Docker CE installed, it’s time to test everything working as expected.

To do this, we need a container image to use for testing. Luckily, there is an image already available for testing purposes. Let’s test the installation by running the hello-world container by running the following command.

sudo docker pull hello-world
sudo docker run hello-world

This command will pull the latest hello-world image from the Docker hub and will run it as a container. It writes Hello from Docker! Message on your Terminal and exits, as shown below.

Pull and run Docker image

This output confirms the installation was successful.

If not, then there is something wrong with the Docker package, or the user has not been added to the Docker group.

Step 6: Running a Docker Container for Development Purposes

Now that Docker CE is up and running let’s use it as a development environment for your AlmaLinux 8. When you start the hello-world container in the previous step, you are running a virtual machine (VM) that runs and then leaves after performing activities. It runs, emits the Hello from Docker! output, and exits as soon as it is done.

A Docker Container can be considerably more helpful than this default example. A Docker Container is identical to VMs with one exception: they are less resource-intensive.

Take, for example, running a container using the most recent Ubuntu image available from the Docker hub.

docker pull ubuntu
docker run -it ubuntu

This command will pull the latest image of Ubuntu, and it will run in an interactive session (i.e., it stays attached to your AlmaLinux 8 Terminal), as shown below.

Run image

Your command prompt should change to a hash mark (#) with an id. In this case, it is f5221423e0b9. This indicates that the container is up and running and that you are able to run commands within it.

You can run any commands without the prefix sudo inside the container, as you run this container as a root user. Any changes you made in the container would only affect the container. It will not affect the operating system you are currently logged into (AlmaLinux 8).

Let’s run the apt update command to update the package management system.

apt update

You should see the following output, which means that all is well.

Update image

To exit the container, you can type exit at the prompt and hit Enter.


In this tutorial, we have shown you how to install Docker CE on an AlmaLinux 8 system. We hope it helped you to install Docker, now you are ready to use its various facilities.

For more information about Docker, you can check out the official documentation.