How to install Docker on Rocky Linux 9.2

To Install Docker On Rocky Linux 9.2

Introduction

The Docker application makes it easy to run application processes within containers. Containers are like virtual machines, but they are portable, resource-friendly, and dependent on the host OS. The Docker application makes it easy to run application processes within containers. Containers are like virtual machines, but they are portable, resource-friendly, and dependent on the host OS.

Installation steps:

Step 1 : Check the OS version by using the below command

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.2 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

Step 2: Update the package database by using the below command

[root@Linuxhelp ~]# dnf check-update
Last metadata expiration check: 1:38:15 ago on Tuesday 31 October 2023 11:15:10 AM.
NetworkManager.x86_64                                       1:1.42.2-8.el9_2                          baseos   
NetworkManager-adsl.x86_64                                  1:1.42.2-8.el9_2                          baseos   
NetworkManager-bluetooth.x86_64                             1:1.42.2-8.el9_2                          baseos   
NetworkManager-config-server.noarch                         1:1.42.2-8.el9_2                          baseos   
NetworkManager-libnm.x86_64                                 1:1.42.2-8.el9_2                          baseos   
NetworkManager-team.x86_64                                  1:1.42.2-8.el9_2                          baseos   
NetworkManager-tui.x86_64                                   1:1.42.2-8.el9_2                          baseos   
NetworkManager-wifi.x86_64                                  1:1.42.2-8.el9_2                          baseos   
NetworkManager-wwan.x86_64                                  1:1.42.2-8.el9_2                          baseos   
bind-libs.x86_64                                            32:9.16.23-11.el9_2.2                     appstream
bind-license.noarch                                         32:9.16.23-11.el9_2.2                     appstream
bind-utils.x86_64                                           32:9.16.23-11.el9_2.2                     appstream
bpftool.x86_64                                              7.0.0-284.30.1.el9_2                      baseos   
sos.noarch                                                  4.6.0-2.el9                               baseos   
systemd.x86_64                                              252-14.el9_2.3.0.1                        baseos   
systemd-libs.x86_64                                         252-14.el9_2.3.0.1                        baseos   
systemd-pam.x86_64                                          252-14.el9_2.3.0.1                        baseos   
systemd-rpm-macros.noarch                                   252-14.el9_2.3.0.1                        baseos   
systemd-udev.x86_64                                         252-14.el9_2.3.0.1                        baseos   

Step 3: Add the official Docker repository by using the below command

[root@Linuxhelp ~]# 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

Step 4: Install Docker, which is composed of three packages by using the following command

[root@Linuxhelp ~]# dnf install docker-ce docker-ce-cli containerd.io
Docker CE Stable - x86_64                                                       95 kB/s |  32 kB     00:00    
Dependencies resolved.
===============================================================================================================
 Package                            Architecture    Version                    Repository                 Size
===============================================================================================================
Installing:
 containerd.io                      x86_64          1.6.24-3.1.el9             docker-ce-stable           33 M
 docker-ce                          x86_64          3:24.0.7-1.el9             docker-ce-stable           24 M
 docker-ce-cli                      x86_64          1:24.0.7-1.el9             docker-ce-stable          7.1 M
Installing weak dependencies:
 docker-buildx-plugin               x86_64          0.11.2-1.el9               docker-ce-stable           13 M
 docker-ce-rootless-extras          x86_64          24.0.7-1.el9               docker-ce-stable          3.9 M
 docker-compose-plugin              x86_64          2.21.0-1.el9               docker-ce-stable           13 M

Transaction Summary
===============================================================================================================
Install  6 Packages

Total download size: 93 M
Installed size: 367 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): docker-ce-24.0.7-1.el9.x86_64.rpm                                        21 MB/s |  24 MB     00:01    
(2/6): docker-buildx-plugin-0.11.2-1.el9.x86_64.rpm                            7.6 MB/s |  13 MB     00:01    
(3/6): docker-ce-rootless-extras-24.0.7-1.el9.x86_64.rpm                       9.1 MB/s | 3.9 MB     00:00    
(4/6): docker-ce-cli-24.0.7-1.el9.x86_64.rpm                                   6.0 MB/s | 7.1 MB     00:01    
(5/6): containerd.io-1.6.24-3.1.el9.x86_64.rpm                                 9.5 MB/s |  33 MB     00:03    
(6/6): docker-compose-plugin-2.21.0-1.el9.x86_64.rpm                           6.8 MB/s |  13 MB     00:01    
---------------------------------------------------------------------------------------------------------------
Total                                                                           23 MB/s |  93 MB     00:04     
Docker CE Stable - x86_64                                                       12 kB/s | 1.6 kB     00:00    
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-compose-plugin-2.21.0-1.el9.x86_64                                             1/6 
  Running scriptlet: docker-compose-plugin-2.21.0-1.el9.x86_64                                             1/6 
  Installing       : docker-buildx-plugin-0.11.2-1.el9.x86_64                                              2/6 
  Running scriptlet: docker-buildx-plugin-0.11.2-1.el9.x86_64                                              2/6 
  Installing       : docker-ce-cli-1:24.0.7-1.el9.x86_64                                                   3/6 
  Running scriptlet: docker-ce-cli-1:24.0.7-1.el9.x86_64                                                   3/6 
  Installing       : containerd.io-1.6.24-3.1.el9.x86_64                                                   4/6 
  Running scriptlet: containerd.io-1.6.24-3.1.el9.x86_64                                                   4/6 
  Installing       : docker-ce-rootless-extras-24.0.7-1.el9.x86_64                                         5/6 
  Running scriptlet: docker-ce-rootless-extras-24.0.7-1.el9.x86_64                                         5/6 
  Installing       : docker-ce-3:24.0.7-1.el9.x86_64                                                       6/6 
  Running scriptlet: docker-ce-3:24.0.7-1.el9.x86_64                                                       6/6 
  Verifying        : containerd.io-1.6.24-3.1.el9.x86_64                                                   1/6 
  Verifying        : docker-buildx-plugin-0.11.2-1.el9.x86_64                                              2/6 
  Verifying        : docker-ce-3:24.0.7-1.el9.x86_64                                                       3/6 
  Verifying        : docker-ce-cli-1:24.0.7-1.el9.x86_64                                                   4/6 
  Verifying        : docker-ce-rootless-extras-24.0.7-1.el9.x86_64                                         5/6 
  Verifying        : docker-compose-plugin-2.21.0-1.el9.x86_64                                             6/6 

Installed:
  containerd.io-1.6.24-3.1.el9.x86_64                      docker-buildx-plugin-0.11.2-1.el9.x86_64            
  docker-ce-3:24.0.7-1.el9.x86_64                          docker-ce-cli-1:24.0.7-1.el9.x86_64                 
  docker-ce-rootless-extras-24.0.7-1.el9.x86_64            docker-compose-plugin-2.21.0-1.el9.x86_64           

Complete!

Step 5: After installation has completed, start the Docker daemon by using the below command

[root@Linuxhelp ~]# systemctl start docker

Step 6: Check the status of the Docker by using the below command

[root@Linuxhelp ~]# systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; preset: disabled)
     Active: active (running) since Tue 2023-10-31 12:57:33 IST; 42s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 36953 (dockerd)
      Tasks: 9
     Memory: 28.8M
        CPU: 453ms
     CGroup: /system.slice/docker.service
             └─36953 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Oct 31 12:57:30 Linuxhelp systemd[1]: Starting Docker Application Container Engine...
Oct 31 12:57:30 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:30.486904088+05:30" level=info msg="Starting >
Oct 31 12:57:30 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:30.566296779+05:30" level=info msg="Loading c>
Oct 31 12:57:32 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:32.727253947+05:30" level=info msg="Firewalld>
Oct 31 12:57:33 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:33.175714134+05:30" level=info msg="Loading c>
Oct 31 12:57:33 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:33.230341751+05:30" level=info msg="Docker da>
Oct 31 12:57:33 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:33.230664459+05:30" level=info msg="Daemon ha>
Oct 31 12:57:33 Linuxhelp dockerd[36953]: time="2023-10-31T12:57:33.320137152+05:30" level=info msg="API liste>
Oct 31 12:57:33 Linuxhelp systemd[1]: Started Docker Application Container Engine.
lines 1-21/21 (END)

Step 7: Make sure it starts at every server reboot by using the below command

[root@Linuxhelp ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Docker on Rocky Linux 9.2. Your feedback is much welcome.

FAQ
Q
Do I lose my data when the container exits?
A
Any data your application writes to disk gets preserved in its container until you explicitly delete it. The file system for the container persists even after the container halts.
Q
What is Docker Image?
A
A Docker image packs up the application and environment required by the application to run
Q
What is a Docker Container?
A
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
Q
What are the repositories used to install Docker?
A
The repositories to install Docker
*docker-ce.repo
*docker-ce-nightly
Q
Which command is used to create a Docker image from a Dockerfile?
A
"docker build" is the command to create a Docker image from a Docker file.