How to install Docker CE on AlmaLinux 8 or Rocky Linux 8

Docker is an open source project that allows you to create, test, and deploy applications quickly and easily. Docker organizes software in containers that contain everything the software needs to run, e.g. B. Libraries, system tools, code and runtime. With Docker, you can quickly deploy and scale applications in any environment. Developers can use the development environments on Windows, Linux or macOS.

In this tutorial we will learn how to install Docker CE on AlmaLinux 8. The steps also apply to Rocky Linux 8, CentOS 8 and REHL.

Step 1: add repository for Docker

You can add the official Docker CE repository to your AlamLinux 8 so that we can install it without having to manually download the packages. The repository can be installed with a single command.

$ sudo dnf config-manager --add-repo=

Step 2: Run the AlmaLinux / Rocky system update

In order for the system to recognize the recently added Docker repository and the packages available in it, you must first run the system update which will rebuild the AlmaLinux system repository cache.

$ sudo dnf update

You can check the repository list to see if the newly added repository exists.

$ sudo dnf repolist -v

Step 3: Install Docker CE Engine on AlmaLinux 8 or Rocky Linux 8

Now that we’ve added the Docker repository to our system, we can install Docker-CE as well as its command line tool and to manage the container lifecycle of its host system with dnf.

$ sudo dnf install docker-ce docker-ce-cli

Step 4: start Docker

After the installation is complete, you can start the Docker service and set it to start automatically when the system starts.

$ sudo systemctl start docker
$ sudo systemctl enable docker

To check the status of the Docker service, enter:

$ systemctl status docker

Press q to return to the command prompt.

Step 5: running Docker commands without sudo

By default, the docker command can only be run as the root user. To avoid the need for root access to run Docker commands, you can add your current system user to the Docker group so that you can quickly run the Docker command without prefixing it with sudo.

$ sudo usermod -aG docker $USER

Where $ USER is the environment variable that contains your user name.

Now you can check whether your user is in the Docker group or not.

id $USER

You can change $ USER in the above command with the specific system user if you want to give a different user the permissions to manage Docker than the current one.

You can sign out and sign back in to update the group membership session.

Step 6: check the Docker installation

To verify the installation, we can run a test container that will access and download an image from the Docker hub.

Enter the following to verify the Docker installation:

$ docker container run hello-world

Docker will first look locally for the hello-world image, if it is not found, download the image from Docker Hub. After the image is downloaded, the Docker daemon creates a new container from this image and the application in the container runs to print the message.

Use Docker commands

Let’s review some basic Docker commands. Run the docker info command to get information like installed Docker version, operating system version, CPU, kernel information, and more.

$ sudo docker info

To search images available on Docker Hub, use Docker search followed by the image name. For example, to browse an Ubuntu image, type:

$ docker search ubuntu


NAME                                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
 ubuntu                                                    Ubuntu is a Debian-based Linux operating sys…   12724     [OK]
 dorowu/ubuntu-desktop-lxde-vnc                            Docker image to provide HTML5 VNC interface …   563                  [OK]
 websphere-liberty                                         WebSphere Liberty multi-architecture images …   280       [OK]
 rastasheep/ubuntu-sshd                                    Dockerized SSH service, built on top of offi…   255                  [OK]
 consol/ubuntu-xfce-vnc                                    Ubuntu container with "headless" VNC session…   241                  [OK]
 ubuntu-upstart                                            DEPRECATED, as is Upstart (find other proces…   113       [OK]
 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5      ubuntu-16-nginx-php-phpmyadmin-mysql-5          50                   [OK]
 open-liberty                                              Open Liberty multi-architecture images based…   48        [OK]
 ubuntu-debootstrap                                        DEPRECATED; use "ubuntu" instead                44        [OK]
 i386/ubuntu                                               Ubuntu is a Debian-based Linux operating sys…   25

The Officially OK column shows that this image is the original image supported by the company behind this project.

To download the official Ubuntu image, enter:

$ docker pull ubuntu

Enter the following to view the downloaded images:

$ docker images


 ubuntu        latest    fb52e22af1b0   6 days ago     72.8MB
 hello-world   latest    d1165f221234   6 months ago   13.3kB

To run the Ubuntu container, type:

$ docker run -it ubuntu




In this tutorial we learned how to successfully install Docker in AlmaLinux 8. The steps mentioned for installing Docker also apply to Rocky Linux 8, CentOS 8 and RHEL.

Leave a Comment

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