How to Install Docker on Rocky Linux 9

Docker is a container engine that uses the Linux Kernel to create the containers on top of an operating system. Which is used to create, deploy and run the applications.

First, check and install any pending system updates.

dnf update 

Adding Docker repository

Enable the Docker CE repository by running the following command.

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

Output:

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

Installing Docker-ce package

Install the Docker-ce package on Rocky Linux 9 by running the following command.

dnf -y  install docker-ce --nobest
dnf install docker-ce --allowerasing -y

Output:

[root@server ~]# dnf -y  install docker-ce --nobest
Docker CE Stable - x86_64                                                      9.6 kB/s | 5.8 kB     00:00
Dependencies resolved.
===============================================================================================================
 Package                            Architecture    Version                    Repository                 Size
===============================================================================================================
Installing:
 docker-ce                          x86_64          3:20.10.16-3.el9           docker-ce-stable           21 M
Installing dependencies:
 container-selinux                  noarch          3:2.179.1-1.el9_0          appstream                  45 k
 containerd.io                      x86_64          1.6.4-3.1.el9              docker-ce-stable           32 M
 docker-ce-cli                      x86_64          1:20.10.16-3.el9           docker-ce-stable           29 M
 docker-ce-rootless-extras          x86_64          20.10.16-3.el9             docker-ce-stable          3.8 M
 fuse-common                        x86_64          3.10.2-5.el9               baseos                    8.0 k
 fuse-overlayfs                     x86_64          1.8.2-1.el9                appstream                  71 k
 fuse3                              x86_64          3.10.2-5.el9               appstream                  53 k
 fuse3-libs                         x86_64          3.10.2-5.el9               appstream                  91 k
 libslirp                           x86_64          4.4.0-7.el9                appstream                  68 k
 slirp4netns                        x86_64          1.1.12-4.el9               appstream                  44 k
 tar                                x86_64          2:1.34-3.el9               baseos                    880 k

Enable and Start the Docker service.

systemctl enable --now docker

systemctl start docker

Output:

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

Check the Status of Docker Service

To verify the Docker service is running, use the following command,

systemctl status  docker

Output:

[root@server ~]# systemctl status  docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: >
     Active: activating (auto-restart) (Result: exit-code) since Mon 2022-07-18 17:05>
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
    Process: 3014 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/co>
   Main PID: 3014 (code=exited, status=1/FAILURE)
        CPU: 108ms

DONE!