How to Install Docker on Rocky Linux 9 Step-by-Step

In this guide, we will cover how to install Docker on Rocky Linux 9 step by step. Additionally we also cover how to install Docker Compose.

As we all know that Docker Container is the highly demanded technology in IT world.  With help of Docker containers, developers and infra admins can package their application and its dependencies and can run it in one computing setup to another.

Prerequisites

  • 2 GB RAM or higher
  • 2 vCPU / CPU (64-bit Processor)
  • Minimal Installed Rocky Linux 9/8
  • Sudo User with privileges
  • 20 GB Free Space on /var
  • 1 Nic Card
  • Stable Internet Connection

Let’s deep dive into Docker Installation steps,

Step 1) Install Updates

Login to Rocky Linux and install all the available updates and then reboot the system once, run commands.

$ sudo dnf update -y
$ reboot

Step 2) Add Docker Repository

Before starting docker installation, please make sure podman and buildah are removed from your rocky linux otherwise you will get errors. Run following command to remove them,

$ sudo dnf remove podman buildah -y

After the removal of podman and buildah, configure docker official package repository using the following command,

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

Step 3) Install Docker on Rocky Linux 9

Now run the following dnf command to install docker,

$ sudo dnf install -y docker-ce

Above command will install docker along with all dependencies, output of command would like below:

Install-docker-ce-dnf-command-rocky-linux

Note: In case you are getting container.io error while installing docker-ce package then run following command,

$ sudo dnf install docker-ce --allowerasing -y

Step 4) Start and Enable Docker Service

Once docker is installed then start and enable its service using following systemctl commands,

$ sudo systemctl start docker
$ sudo systemctl enable docker

To verify the status of docker run,

$ sudo systemctl status docker

Docker-Service-Status-Rocky-Linux

Perfect, above output confirms that docker service is up and running.

If you wish to allow local user to mange and run docker commands with sudo, then add the user to docker group using beneath command.

$ sudo usermod -aG docker $USER
$ newgrp docker

Execute following docker command to view its version

$ docker --version
Docker version 24.0.6, build ed223bc
$

Let’s verify the docker installation in the next step.

Step 5) Test Docker Installation

To test docker installation, run hello-world container using following docker command,

$ docker run hello-world

Output,

Docker-Run-Hello-World-Container-Rocky-Linux

Above output confirms that container ‘hello-world’ has been launched successfully and it also confirms that docker is installed successfully.

Step 6) Install Docker Compose

Docker Compose command allows to spin up multiple containers in one go. So, to install it run the following command,

$ sudo dnf install docker-compose-plugin -y

Run beneath command to verify docker compose version,

$ docker compose version
Docker Compose version v2.21.0
$

Above output shows that docker compose of version 2.21.0 is installed successfully. That’s all from guide. I hope you have found it informative. Please do share your feedback and queries in below comments section.

3 thoughts on “How to Install Docker on Rocky Linux 9 Step-by-Step”

  1. Very useful instructions. Thank you.
    Just a minor correction. –allowerassing has one s!
    sudo dnf install docker-ce –allowerasing -y

    Reply

Leave a Comment