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:
-
- A running Rocky Linux 9 server
- Administrative access or a user account with sudo privileges
- 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:
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:
Once you add a repository, execute the following command to install the Docker package:
To verify that Docker is installed correctly, execute the following command:
Enable the Docker Services
Once you install the Docker, start the Docker service and enable it to start on boot:
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:
Similarly, you can download the Rocky Linux 9 Docker image through the following command:
You can also check whether you can download the images from the Docker Hub:
Moreover, you list the currently available Docker images in the system through the following command:
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:
You can install the tools in the Docker container. For example, let’s install the Nginx web server in the container:
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:
Conclusion
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.