Hello, friends. In this post, you will learn how to install Docker CE on Rocky Linux 9 / Alma Linux 9
Docker is a technology that allows us to deploy applications and operating systems in containers that are distributed in images.
We have talked a lot about Docker in this blog, but we haven’t tried it with Rocky Linux 9 / Alma Linux 9, so let’s go for it.
Installing Docker on Rocky Linux 9 / Alma Linux 9
As we all know, the RHEL-derived family relies heavily on Podman as a replacement for Docker. However, often it is useful to know how to install Docker because it is still widely used in the world.
So let’s get started.
First, open a terminal and update the entire operating system
sudo dnf update
As Docker is not present in the official repositories of the distribution, then it is necessary to use an external repository to accomplish the goal.
So, you can add it with the following command
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Sample output:
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
Then you can install Docker with the command
sudo dnf install docker-ce docker-ce-cli containerd.io
This is how fast you can install Docker.
Managing the Docker service on Alma Linux 9 / Rocky Linux 9
Once installed on the system, a service named docker
will be created, and you can use it to correctly manage the Docker execution.
To start Docker run
sudo systemctl start docker
So, If you want to stop it from running for any reason:
sudo systemctl stop docker
When you introduce changes to the tool’s settings, you will be prompted to restart it. To do so, you can run.
sudo systemctl restart docker
Or something more in-depth with
sudo systemctl reload docker
It is also the case that you would like to make Docker start up with the system
sudo systemctl enable docker
You will get an output similar to this
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/system/docker.service.
Of course, it is necessary to check the status of the Docker service. This way you can quickly determine errors and if it is working properly.
sudo systemctl status docker
Sample output:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2023-03-05 16:07:35 UTC; 5s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 12286 (dockerd)
Tasks: 7
Memory: 31.7M
CPU: 300ms
CGroup: /system.slice/docker.service
└─12286 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.063350242Z" level=info msg="[core] [Channel #4 SubChannel #5] Subcha>
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.063368285Z" level=info msg="[core] [Channel #4] Channel Connectivity>
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.095174595Z" level=info msg="Loading containers: start."
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.312348629Z" level=info msg="Default bridge (docker0) is assigned wit>
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.400248267Z" level=info msg="Loading containers: done."
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.414547952Z" level=info msg="Docker daemon" commit=bc3805a graphdrive>
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.414748147Z" level=info msg="Daemon has completed initialization"
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.440143433Z" level=info msg="[core] [Server #7] Server created" modul>
Mar 05 16:07:35 unixcop systemd[1]: Started Docker Application Container Engine.
Mar 05 16:07:35 unixcop dockerd[12286]: time="2023-03-05T16:07:35.451156991Z" level=info msg="API listen on /run/docker.sock"
Now that you know how to handle the service, let’s test it.
Verify the installation of Docker on Rocky Linux 9 / Alma Linux 9
To know if Docker is properly installed, the only thing we have to do is to use it.
By default, you need root permissions to run it, but many times this is not correct. The solution is to add the current user to docker
group.
sudo usermod -aG docker $(whoami)
You can modify the above command to replace the $(whoami)
variable with the user’s name. This is ideal if that user is not logged in.
Exit the terminal and the changes will be applied.
Now, to use Docker and to know if everything has gone well, there is the Hello-world
image. To run it, you can use this command.
docker run hello-world
It will tell you that it is not in the system, but it will be downloaded and once executed. If everything went well, you will see this.
And that’s it! Docker is well installed.
Conclusion
Thanks to this post, you already know how to install Docker on Alma Linux 9 / Rocky Linux 9 and the process is simple.