How to install Docker on AlmaLinux 8.x/9.x?

Welcome to the world of containerization, where Docker has revolutionized the way we develop, package, and deploy applications. If you’re a software developer, you’re probably familiar with the headaches that come with managing dependencies and configuring different environments for your projects. But with Docker, you can create a self-contained environment for your application that can run consistently across different machines and operating systems. Whether you’re working on a small hobby project or a large-scale enterprise application, Docker can help you streamline your development process and get your code running smoothly in production. So, step into the world of Docker, and experience the power of containerization for yourself!

In this article I will be demostrating how you can install Docker on the AlmaLinux 8.x or 9.x quickly.

Why Docker?

If you’re a software developer or IT professional, you’re probably familiar with the challenges that come with managing dependencies and configuring environments for different projects. This can be a time-consuming and often frustrating process that can slow down your development workflow and even cause errors and compatibility issues.

That’s where Docker comes in. Docker is a powerful tool that allows you to create lightweight, portable, and self-contained environments for your applications. With Docker, you can package your application and all its dependencies into a single container that can be run consistently across different machines and operating systems, without worrying about version conflicts or other compatibility issues.

Docker also makes it easy to manage and scale your applications, as you can easily spin up multiple containers with identical environments to handle increased traffic or workload. This can be especially useful in cloud environments where resources are shared and scaling is critical to maintaining performance.

Another benefit of Docker is its flexibility. With a vast repository of pre-built images and the ability to easily create custom images, you can quickly set up and configure your environment to meet your specific needs. And with its open-source nature, Docker has a large and active community that constantly contributes new features and tools to make it even more powerful and user-friendly.

Overall, if you’re looking to streamline your development workflow, improve application compatibility and portability, and scale your applications easily and efficiently, then Docker is definitely worth considering. With its powerful features and flexible architecture, Docker is quickly becoming a must-have tool for modern software development and IT operations.

somesh-playing-with-containers

Prerequisites

  • AlmaLinux 8.x/9.x
  • Minimum 2vCPUs
  • Minimum 2G RAM
  • Cup of Tea or Coffee ☕

Shall we start the installation? 🤔

Enable the Docker Repository

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

Install Docker

dnf install -y docker-ce docker-ce-cli docker-compose-plugin containerd.io
installation-of-docker-packages

Start & Enable the Docker

systemctl start docker
systemctl enable docker

Verify the Docker Service & Version

[root@somesh-lab ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-04-24 22:01:32 UTC; 14s ago
     Docs: https://docs.docker.com
 Main PID: 4206 (dockerd)
    Tasks: 8
   Memory: 30.6M
   CGroup: /system.slice/docker.service
           └─4206 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
[root@somesh-lab ~]# docker --version
Docker version 23.0.4, build f480fb1

Let’s setup HTTPD (Apache) Server on Docker

Pull the HTTPD (Apache) Docker Image

[root@somesh-lab ~]# docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
26c5c85e47da: Pull complete
2d29d3837df5: Pull complete
2483414a5e59: Pull complete
e78016c4ba87: Pull complete
757908175415: Pull complete
Digest: sha256:a182ef2350699f04b8f8e736747104eb273e255e818cd55b6d7aa50a1490ed0c
Status: Downloaded newer image for httpd:latest
docker.io/library/httpd:latest

List all of the images that were pulled.

[root@somesh-lab ~]# docker image ls
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
httpd        latest    4b7fc736cb48   12 days ago   145MB

Run the docker container with the HTTPD Image.

[root@somesh-lab ~]# docker run -d -t --name somesh-apacheserver -p 80:80 httpd
6a555b5f06ed06a64d4be90756c01aec4b84f1636c74e3ab5b81587356c48f3f

Yolaaa!!! We have created a docker container with HTTPD (Apache) Image. You can list the docker containers with the following command.

[root@somesh-lab ~]# docker ps
CONTAINER ID   IMAGE     COMMAND              CREATED              STATUS              PORTS                               NAMES
6a555b5f06ed   httpd     "httpd-foreground"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp, :::80->80/tcp   somesh-apacheserver

You can now visit the IP address of the server and you should see “It Works!“.

it-works-apache-httpd-docker-container-img

Don’t worry! 😁 Let me break down the Docker Run command for you,

How-to-install-Docker-on-AlmaLinux-8-9

You can also remove the Docker Container

[root@somesh-lab ~]# docker stop somesh-apacheserver
somesh-apacheserver
[root@somesh-lab ~]# docker rm  somesh-apacheserver
somesh-apacheserver

Verify the Docker Container is removed

[root@somesh-lab ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

Conclusion

We have seen how easy it is to install Docker on AlmaLinux 8.x/9.x. With just a few simple commands, you can have Docker up and running on your system in no time. Once you have Docker installed, you can start creating containers for your applications and enjoy the benefits of containerization, such as improved portability, scalability, and ease of deployment.

Docker is an essential tool for modern software development and IT operations, and by mastering its use, you can streamline your workflow and stay ahead of the competition. So why not give Docker a try today? With its vast repository of pre-built images and active community, you can start building and deploying your applications with ease and confidence.