How to Install Docker on Rocky Linux and AlmaLinux

Docker is a popular containerization platform used for creating and managing lightweight, portable, and self-contained applications. Docker containers are isolated from the underlying host system and can run on any operating system that supports Docker. In this blog, we will discuss how to install Docker on Rocky Linux and AlmaLinux, two popular Linux distributions that have gained popularity in recent times.

Prerequisites

Before we proceed with the installation process, make sure you have the following prerequisites:

  • A running instance of Rocky Linux or AlmaLinux.
  • A user account with sudo privileges.
  • A stable internet connection.

Steps to Install Docker on Rocky Linux and AlmaLinux

Step 1: Update the Rocky Linux 

Before installing Docker, make sure your system is up to date. You can do this by running the following command:

sudo dnf update

This will update all the packages and dependencies on your system.

Step 2: Add Docker repository in Rocky Linux

sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Sample Output:

[sysadminxpert@RockyLinux ~]$ sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
[sysadminxpert@RockyLinux ~]$

Step 3: Install Docker on Rocky Linux 

Once your system is updated, you can proceed with the installation of Docker. Docker is not available in the default package repositories of Rocky Linux and AlmaLinux. You can install it by running the following command:

sudo dnf install docker-ce docker-ce-cli containerd.io

Install Docker on Rocky Linux

Sample Output:

[sysadminxpert@RockyLinux ~]$ sudo dnf install docker-ce docker-ce-cli containerd.io
Last metadata expiration check: 1:28:03 ago on Thu 30 Mar 2023 10:18:03 AM EDT.
Dependencies resolved.
================================================================================================================================================================================
Package Architecture Version Repository Size
================================================================================================================================================================================
Installing:
containerd.io x86_64 1.6.19-3.1.el8 docker-ce-stable 34 M
docker-ce x86_64 3:23.0.2-1.el8 docker-ce-stable 23 M
docker-ce-cli x86_64 1:23.0.2-1.el8 docker-ce-stable 7.1 M
Installing dependencies:
checkpolicy x86_64 2.9-1.el8 baseos 345 k
container-selinux noarch 2:2.189.0-1.module+el8.7.0+1154+147ffa21 appstream 59 k
docker-ce-rootless-extras x86_64 23.0.2-1.el8 docker-ce-stable 4.8 M
fuse-overlayfs x86_64 1.9-1.module+el8.7.0+1154+147ffa21 appstream 72 k
fuse3 x86_64 3.3.0-16.el8 baseos 53 k
fuse3-libs x86_64 3.3.0-16.el8 baseos 94 k
libcgroup x86_64 0.41-19.el8 baseos 69 k
libslirp x86_64 4.4.0-1.module+el8.7.0+1154+147ffa21 appstream 69 k
policycoreutils-python-utils noarch 2.9-20.el8 baseos 252 k
python3-audit x86_64 3.0.7-4.el8 baseos 86 k
python3-libsemanage x86_64 2.9-9.el8_6 baseos 127 k
python3-policycoreutils noarch 2.9-20.el8 baseos 2.2 M
python3-setools x86_64 4.3.0-3.el8 baseos 623 k
slirp4netns x86_64 1.2.0-2.module+el8.7.0+1154+147ffa21 appstream 53 k
Installing weak dependencies:
docker-buildx-plugin x86_64 0.10.4-1.el8 docker-ce-stable 12 M
docker-compose-plugin x86_64 2.17.2-1.el8 docker-ce-stable 12 M
docker-scan-plugin x86_64 0.23.0-3.el8 docker-ce-stable 3.8 M

Transaction Summary
================================================================================================================================================================================
Install 20 Packages

Total size: 101 M
Total download size: 84 M
Installed size: 378 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] container-selinux-2.189.0-1.module+el8.7.0+1154+147ffa21.noarch.rpm: Already downloaded
[SKIPPED] fuse-overlayfs-1.9-1.module+el8.7.0+1154+147ffa21.x86_64.rpm: Already downloaded
[SKIPPED] libslirp-4.4.0-1.module+el8.7.0+1154+147ffa21.x86_64.rpm: Already downloaded
[SKIPPED] slirp4netns-1.2.0-2.module+el8.7.0+1154+147ffa21.x86_64.rpm: Already downloaded
[SKIPPED] checkpolicy-2.9-1.el8.x86_64.rpm: Already downloaded
[SKIPPED] fuse3-3.3.0-16.el8.x86_64.rpm: Already downloaded
[SKIPPED] fuse3-libs-3.3.0-16.el8.x86_64.rpm: Already downloaded
[SKIPPED] libcgroup-0.41-19.el8.x86_64.rpm: Already downloaded
[SKIPPED] policycoreutils-python-utils-2.9-20.el8.noarch.rpm: Already downloaded
[SKIPPED] python3-audit-3.0.7-4.el8.x86_64.rpm: Already downloaded
[SKIPPED] python3-libsemanage-2.9-9.el8_6.x86_64.rpm: Already downloaded
[SKIPPED] python3-policycoreutils-2.9-20.el8.noarch.rpm: Already downloaded
[SKIPPED] python3-setools-4.3.0-3.el8.x86_64.rpm: Already downloaded
[SKIPPED] docker-buildx-plugin-0.10.4-1.el8.x86_64.rpm: Already downloaded
(15/20): docker-ce-cli-23.0.2-1.el8.x86_64.rpm 252 kB/s | 7.1 MB 00:28
(16/20): docker-ce-rootless-extras-23.0.2-1.el8.x86_64.rpm 290 kB/s | 4.8 MB 00:16
(17/20): docker-ce-23.0.2-1.el8.x86_64.rpm 509 kB/s | 23 MB 00:47
(18/20): docker-scan-plugin-0.23.0-3.el8.x86_64.rpm 396 kB/s | 3.8 MB 00:09
(19/20): docker-compose-plugin-2.17.2-1.el8.x86_64.rpm 867 kB/s | 12 MB 00:13
(20/20): containerd.io-1.6.19-3.1.el8.x86_64.rpm 520 kB/s | 34 MB 01:06
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.3 MB/s | 84 MB 01:06
warning: /var/cache/dnf/docker-ce-stable-fa9dc42ab4cec2f4/packages/containerd.io-1.6.19-3.1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Docker CE Stable - x86_64 337 B/s | 1.6 kB 00:04
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : docker-scan-plugin-0.23.0-3.el8.x86_64 1/20
Running scriptlet: docker-scan-plugin-0.23.0-3.el8.x86_64 1/20
Installing : docker-compose-plugin-2.17.2-1.el8.x86_64 2/20
Running scriptlet: docker-compose-plugin-2.17.2-1.el8.x86_64 2/20
Installing : fuse3-libs-3.3.0-16.el8.x86_64 3/20
Running scriptlet: fuse3-libs-3.3.0-16.el8.x86_64 3/20
Installing : fuse3-3.3.0-16.el8.x86_64 4/20
Installing : fuse-overlayfs-1.9-1.module+el8.7.0+1154+147ffa21.x86_64 5/20
Running scriptlet: fuse-overlayfs-1.9-1.module+el8.7.0+1154+147ffa21.x86_64 5/20
Installing : docker-buildx-plugin-0.10.4-1.el8.x86_64 6/20
Running scriptlet: docker-buildx-plugin-0.10.4-1.el8.x86_64 6/20
Installing : docker-ce-cli-1:23.0.2-1.el8.x86_64 7/20
Running scriptlet: docker-ce-cli-1:23.0.2-1.el8.x86_64 7/20
Installing : python3-setools-4.3.0-3.el8.x86_64 8/20
Installing : python3-libsemanage-2.9-9.el8_6.x86_64 9/20
Installing : python3-audit-3.0.7-4.el8.x86_64 10/20
Running scriptlet: libcgroup-0.41-19.el8.x86_64 11/20
Installing : libcgroup-0.41-19.el8.x86_64 11/20
Running scriptlet: libcgroup-0.41-19.el8.x86_64 11/20
Installing : checkpolicy-2.9-1.el8.x86_64 12/20
Installing : python3-policycoreutils-2.9-20.el8.noarch 13/20
Installing : policycoreutils-python-utils-2.9-20.el8.noarch 14/20
Running scriptlet: container-selinux-2:2.189.0-1.module+el8.7.0+1154+147ffa21.noarch 15/20
Installing : container-selinux-2:2.189.0-1.module+el8.7.0+1154+147ffa21.noarch 15/20
Running scriptlet: container-selinux-2:2.189.0-1.module+el8.7.0+1154+147ffa21.noarch 15/20
Installing : containerd.io-1.6.19-3.1.el8.x86_64 16/20
Running scriptlet: containerd.io-1.6.19-3.1.el8.x86_64 16/20
Installing : libslirp-4.4.0-1.module+el8.7.0+1154+147ffa21.x86_64 17/20
Installing : slirp4netns-1.2.0-2.module+el8.7.0+1154+147ffa21.x86_64 18/20
Installing : docker-ce-rootless-extras-23.0.2-1.el8.x86_64 19/20
Running scriptlet: docker-ce-rootless-extras-23.0.2-1.el8.x86_64 19/20
Installing : docker-ce-3:23.0.2-1.el8.x86_64 20/20
Running scriptlet: docker-ce-3:23.0.2-1.el8.x86_64 20/20
Running scriptlet: container-selinux-2:2.189.0-1.module+el8.7.0+1154+147ffa21.noarch 20/20
Running scriptlet: docker-ce-3:23.0.2-1.el8.x86_64 20/20
Verifying : container-selinux-2:2.189.0-1.module+el8.7.0+1154+147ffa21.noarch 1/20
Verifying : fuse-overlayfs-1.9-1.module+el8.7.0+1154+147ffa21.x86_64 2/20
Verifying : libslirp-4.4.0-1.module+el8.7.0+1154+147ffa21.x86_64 3/20
Verifying : slirp4netns-1.2.0-2.module+el8.7.0+1154+147ffa21.x86_64 4/20
Verifying : checkpolicy-2.9-1.el8.x86_64 5/20
Verifying : fuse3-3.3.0-16.el8.x86_64 6/20
Verifying : fuse3-libs-3.3.0-16.el8.x86_64 7/20
Verifying : libcgroup-0.41-19.el8.x86_64 8/20
Verifying : policycoreutils-python-utils-2.9-20.el8.noarch 9/20
Verifying : python3-audit-3.0.7-4.el8.x86_64 10/20
Verifying : python3-libsemanage-2.9-9.el8_6.x86_64 11/20
Verifying : python3-policycoreutils-2.9-20.el8.noarch 12/20
Verifying : python3-setools-4.3.0-3.el8.x86_64 13/20
Verifying : containerd.io-1.6.19-3.1.el8.x86_64 14/20
Verifying : docker-buildx-plugin-0.10.4-1.el8.x86_64 15/20
Verifying : docker-ce-3:23.0.2-1.el8.x86_64 16/20
Verifying : docker-ce-cli-1:23.0.2-1.el8.x86_64 17/20
Verifying : docker-ce-rootless-extras-23.0.2-1.el8.x86_64 18/20
Verifying : docker-compose-plugin-2.17.2-1.el8.x86_64 19/20
Verifying : docker-scan-plugin-0.23.0-3.el8.x86_64 20/20

Installed:
checkpolicy-2.9-1.el8.x86_64 container-selinux-2:2.189.0-1.module+el8.7.0+1154+147ffa21.noarch containerd.io-1.6.19-3.1.el8.x86_64
docker-buildx-plugin-0.10.4-1.el8.x86_64 docker-ce-3:23.0.2-1.el8.x86_64 docker-ce-cli-1:23.0.2-1.el8.x86_64
docker-ce-rootless-extras-23.0.2-1.el8.x86_64 docker-compose-plugin-2.17.2-1.el8.x86_64 docker-scan-plugin-0.23.0-3.el8.x86_64
fuse-overlayfs-1.9-1.module+el8.7.0+1154+147ffa21.x86_64 fuse3-3.3.0-16.el8.x86_64 fuse3-libs-3.3.0-16.el8.x86_64
libcgroup-0.41-19.el8.x86_64 libslirp-4.4.0-1.module+el8.7.0+1154+147ffa21.x86_64 policycoreutils-python-utils-2.9-20.el8.noarch
python3-audit-3.0.7-4.el8.x86_64 python3-libsemanage-2.9-9.el8_6.x86_64 python3-policycoreutils-2.9-20.el8.noarch
python3-setools-4.3.0-3.el8.x86_64 slirp4netns-1.2.0-2.module+el8.7.0+1154+147ffa21.x86_64

Complete!
[sysadminxpert@RockyLinux ~]$

This command will download and install the latest version of Docker on your system. Once the installation is complete, you can check the version of Docker by running the following command:

docker –version

Sample Output

[sysadminxpert@RockyLinux ~]$ docker --version
Docker version 23.0.2, build 569dd73

Step 4: Start and enable Docker

After installing Docker, you need to start the Docker service and enable it to start automatically at boot time. You can do this by running the following commands:

sudo systemctl start docker

sudo systemctl enable docker

The first command will start the Docker service, and the second command will enable it to start automatically at boot time.

Sample Output

[sysadminxpert@RockyLinux ~]$ sudo systemctl start docker
[sysadminxpert@RockyLinux ~]$ sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[sysadminxpert@RockyLinux ~]$

Step 5: Check Docker Status

sudo systemctl status docker

Install Docker on Rocky Linux

Sample Output

[sysadminxpert@RockyLinux ~]$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2023-03-30 11:50:18 EDT; 2min 2s ago
Docs: https://docs.docker.com
Main PID: 7220 (dockerd)
Tasks: 8
Memory: 28.1M
CGroup: /system.slice/docker.service
└─7220 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Mar 30 11:50:15 RockyLinux dockerd[7220]: time="2023-03-30T11:50:15.501972757-04:00" level=info msg="[core] [Channel #4] Channel Connectivity change to READY" module=grpc
Mar 30 11:50:15 RockyLinux dockerd[7220]: time="2023-03-30T11:50:15.578395805-04:00" level=info msg="Loading containers: start."
Mar 30 11:50:17 RockyLinux dockerd[7220]: time="2023-03-30T11:50:17.194289592-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Dae>
Mar 30 11:50:17 RockyLinux dockerd[7220]: time="2023-03-30T11:50:17.573488208-04:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Mar 30 11:50:17 RockyLinux dockerd[7220]: time="2023-03-30T11:50:17.912420531-04:00" level=info msg="Loading containers: done."
Mar 30 11:50:17 RockyLinux dockerd[7220]: time="2023-03-30T11:50:17.957827173-04:00" level=info msg="Docker daemon" commit=219f21b graphdriver=overlay2 version=23.0.2
Mar 30 11:50:17 RockyLinux dockerd[7220]: time="2023-03-30T11:50:17.957960448-04:00" level=info msg="Daemon has completed initialization"
Mar 30 11:50:18 RockyLinux dockerd[7220]: time="2023-03-30T11:50:18.017836774-04:00" level=info msg="[core] [Server #7] Server created" module=grpc
Mar 30 11:50:18 RockyLinux systemd[1]: Started Docker Application Container Engine.
Mar 30 11:50:18 RockyLinux dockerd[7220]: time="2023-03-30T11:50:18.040920683-04:00" level=info msg="API listen on /run/docker.sock"

[sysadminxpert@RockyLinux ~]$

Step 6: Verify Docker Installation

To verify that Docker is installed correctly, you can run the following command:

sudo docker run hello-world

This command will download and run a Docker container called “hello-world.” If everything is installed correctly, you should see the following output:

Hello from Docker!

This message shows that your installation appears to be working correctly.

Install Docker on Rocky Linux

Sample Output

[sysadminxpert@RockyLinux ~]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:ffb13da98453e0f04d33a6eee5bb8e46ee50d08ebe17735fc0779d0349e889e9
Status: Downloaded newer image for hello-world:latest

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/

[sysadminxpert@RockyLinux ~]$

Congratulations! You have successfully installed Docker on your Rocky Linux or AlmaLinux system.

Conclusion

In this blog, we discussed how to install Docker on Rocky Linux and AlmaLinux. Docker is a powerful containerization platform that can help you create and manage lightweight, portable, and self-contained applications. By following the steps mentioned in this blog, you can easily install Docker on your Rocky Linux or AlmaLinux system and start using it to deploy your applications.

See also:

Docker Release information

List of monitoring tools 

Linux Blogs

AWS Cloud Blogs

Database Blogs

DevOps Blogs

Interview Questions & Answers

Docker Blogs

Google Cloud Blogs