Rocky Linux

How to Install and Use Docker on Rocky Linux 9

Docker is an open-source and famous platform that automates application deployment and management. It has become one of the best developer tools due to its user-friendly options and powerful capabilities. Docker modifies the software into containers (standardized units) having required codes, libraries, runtime, and system tools. That’s why Docker is widely used to develop the distributed applications as a software development tool.

Docker also offers higher security with less required work with the codes. Hence, mastering the Docker can enhance your productivity and efficiency in software development and deployment workflows. If you are a Rocky Linux 9 user and you want to setup the Docker, this tutorial is for you. Here, we will describe the ways to install and use the Docker on Rocky Linux 9(RHEL-based OS).

How to Install and Use the Docker on Rocky Linux 9

Before moving to the installation process of Docker, it is important to check the following prerequisites:

    1. A running Rocky Linux 9 server
    2. Administrative access or a user account with sudo privileges
    3. Stable internet connectivity to download the Docker packages

Installation Process of Docker

First, update the system as per the latest available update packages in Rocky Linux 9:

sudo dnf update


Docker provides an official repository for CentOS which is compatible with Rocky Linux. It means that you can add the Docker repository by executing the following command:

sudo dnf config-manager --add-repo=


Once you add a repository, execute the following command to install the Docker package:

sudo dnf install docker-ce docker-ce-cli -y


To verify that Docker is installed correctly, execute the following command:

sudo docker info


Enable the Docker Services

Once you install the Docker, start the Docker service and enable it to start on boot:

sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker


How to Use the Docker

Now, you installed the Docker successfully. Here are some commands and usage examples that you can try:

Pulling the Docker Images

A Docker image is a software package that contains code, runtime environment, system tools, libraries, and dependencies to run the software. To download a Docker image, use the “docker pull” command. For example, to pull the official CentOS 8 image, run the following:

sudo docker pull centos:8


Similarly, you can download the Rocky Linux 9 Docker image through the following command:

sudo docker pull rockylinux:9


You can also check whether you can download the images from the Docker Hub:

sudo docker run hello-world


Moreover, you list the currently available Docker images in the system through the following command:

sudo docker images


Running a Docker Container

You can use the run command to launch a Docker container. For instance, to run an interactive session with a Rocky Linux 9 container, execute the following:

sudo docker run -it rockylinux:9


You can install the tools in the Docker container. For example, let’s install the Nginx web server in the container:

dnf install nginx


Managing the Docker Containers

To manage the running Docker containers, you can use the commands such as “docker ps”, “docker stop”, “docker start”, and “docker rm”. These commands allow you to list the containers, stop a container, start a stopped container, and remove a container.

Exit the Docker Container

You can use the following command to exit the Docker container from the terminal:




You have successfully installed and started using the Docker on Rocky Linux 9. By leveraging the Docker, you can benefit from the isolation and portability of containers, enabling an efficient application development, testing, and deployment processes.

Remember to keep your Docker installation updated regularly. Docker frequently releases updates including security patches and feature enhancements. Stay informed about the latest Docker releases and keep your system secure and optimized.

With Docker on Rocky Linux 9, you are well-equipped to embark on a journey of efficient application management and development.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.