How to install Docker on Rocky Linux 9 – Step by Step

Rocky Linux 9 is an RHEL package-based distro. Whereas Docker is a commercial platform used by individuals and businesses to create and run containers. It is open-source software that provides a lightweight alternative to other Type-2 virtualization software. For example – VirtualBox.  Although the pre-built images are available, we can also create our own to run on containers powered by the Docker Engine.

What do we need to perform this tutorial?

  • Rocky Linux 9 installed OS on a physical or virtual machine
  • Virtualization support
  • 4GB of RAM
  • A user with sudo access to install packages
  • Internet access

Docker installation on Rocky Linux 9

1. Check Virtualization Support

To run the virtual containers, we need a system that can support the virtualization. All the modern systems are enabled for that and if not, then we manually have to do that from BIOS. To confirm use this step’s command.

grep --color vmx /proc/cpuinfo

It doesn’t matter which CPU you are using the output must contain VMX  if it is then it means Virtualization is enabled.

Checking virtualization

2. Set Docker Package Source

We cannot install the version of this container service directly using the Rocky Linux 9 repository. To solve this, we manually add Docker’s official repository using the command terminal.

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

Run system update to rebuild DNF cache:

sudo dnf update
Running system update command

3. Use DNF to install Docker on Rocky Linux 9

We already have prepared our Rocky Linux 9 to receive the latest packages of Docker, now, in our terminal use the DNF to install them. Here is the one to follow:

sudo dnf install docker-ce docker-ce-cli containerd.io
Install Docker on Rocky Linux 9

4. Background Service

To ensure the Docker engine keeps running in the background continuously so that our containers won’t get stopped even after restarting the system. We need to start and enable Docker’s service.

sudo systemctl enable docker
sudo systemctl start docker

5. Check Status:

Whether the service which we have just started in the previous step is running perfectly fine or not, run the given command. The output will let you know the same with green Active text.

systemctl status docker --no-pager -l
Docker Service status check

6. Run Docker without sudo

The next task of ours in installing Docker on Rocky Linux 9 is to run it without sudo. By default, a user has to use sudo with every command of Docker to run it. Hence, we add our current user to its group to solve this.

sudo usermod -aG docker $USER

Reload Shell session

newgrp docker

7.  Test with Hello-world Image

The beast is ready on our Linux to create containers with various Linux and app images. But before that, let’s check if is it really working to assure we haven’t done anything wrong in configuring it.

docker run hello-world

The output will give a confirmation message – Hello from Docker!

docker run hello world

8. Update Docker

In the future to get the latest version of this open-source software platform, on your Rocky Linux 9 you just need to run the system update command.

sudo dnf update

9. Uninstall or Remove (optional)

Use the given commands only when you don’t require Docker on Rocky Linux 9. Because it will delete it along with all the containers running using this service.

sudo dnf remove -y docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.