Docker has become an essential tool in modern software development, offering a streamlined way to build, test, and deploy applications within isolated environments known as containers. A container is a compact, self-contained unit that encapsulates the application along with all its dependencies—libraries, configuration files, and runtime requirements—allowing it to run consistently across different computing environments.
This portability and consistency make Docker indispensable for developers today. Whether deploying on local machines or cloud infrastructure, Docker ensures that applications behave the same way everywhere.
Docker offers two primary editions: Docker Community Edition (CE) and Docker Enterprise Edition (EE). The former is open-source and free to use, while the latter is a commercial offering tailored for enterprise environments.
In this guide, we will walk through how to install Docker CE on both Rocky Linux and AlmaLinux distributions.
Step 1: Add Docker Repository on Rocky Linux
By default, Docker is not included in the standard package repositories of Rocky Linux. However, Docker provides an official repository which we can add manually.
To do so, execute the following command in your terminal:
<code>$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo</code>
Step 2: Install Docker in Rocky Linux / AlmaLinux
Once the repository has been added, update your system’s package list before proceeding with the installation.
Run the update command:
<code>$ sudo dnf update</code>
Then install Docker CE, the Docker CLI, and containerd using the following command:
<code>$ sudo dnf install -y docker-ce docker-ce-cli containerd.io</code>
After installation, verify the installed version of Docker:
<code>$ docker --version <strong>Docker version 20.10.8, build 3967b7d</strong></code>
Step 3: Start and Enable Docker Service
Now that Docker is installed, we need to start the Docker service. Before doing so, ensure that it starts automatically at boot time.
Enable the Docker service:
<code>$ sudo systemctl enable docker</code>
Start the Docker daemon:
<code>$ sudo systemctl start docker</code>
Check the status of the Docker service to confirm it's running properly:
<code>$ sudo systemctl status docker</code>
Great! The Docker service is up and running.
Step 4: Add User to the Docker Group
By default, only the root user has permission to execute Docker commands. To allow a regular user to run Docker without sudo privileges, we must add them to the docker group, which is created automatically during installation.
For example, to add the user tecmint
to the docker group:
<code>$ sudo usermod -aG docker tecmint</code>
You can verify the group membership of the user using the id
command:
<code>$ id tecmint</code>
Step 5: Test Docker Installation on Rocky Linux
To verify that Docker is working correctly, let’s run the official hello-world container:
<code>$ docker run hello-world</code>
This command downloads the hello-world image from Docker Hub and runs it inside a container. It outputs a message confirming successful installation.
Let’s try something more advanced. We’ll pull an Ubuntu image and interact with it.
Pull Ubuntu Image
Download the latest Ubuntu image using:
<code>$ docker pull ubuntu</code>
List available images:
<code>$ docker images</code>
Run Ubuntu Container
To access the shell of the Ubuntu container:
<code>$ docker run -it ubuntu</code>
Inside the container, you can run commands just like on a regular Ubuntu system. When finished, type exit
to leave the container environment.
Final Thoughts
That concludes our guide. You now have Docker CE successfully installed on either Rocky Linux or AlmaLinux. You’ve also learned how to pull Docker images and run interactive containers—laying the foundation for further exploration into Docker-based development and deployment workflows.
The above is the detailed content of How to Install Docker on Rocky Linux and AlmaLinux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

There are three ways to create empty files in the command line: First, the simplest and safest use of the touch command, which is suitable for debugging scripts or placeholder files; Second, it is quickly created through > redirection but will clear existing content, which is suitable for initializing log files; Third, use echo"> file name to create a file with an empty string, or use echo-n""> file name to avoid line breaks. These three methods have their own applicable scenarios, and choosing the right method can help you complete the task more efficiently.

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

Eclipse is a free integrated development environment (IDE) that programmers around the world use to write software, primarily in Java, but also in other major programming languages using Eclipse plugins.The latest release of Eclipse IDE 2023?06 does

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Linux has a rich collection of commands, and while many of them are powerful and useful for various tasks, there are also some funny and whimsical commands that you can try out for amusement. 1. sl Command (Steam Locomotive) You might be aware of the

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.
