How to Install Docker CE on AlmaLinux 8 or Rocky Linux 8

Channel: Linux
Abstract: and more. $ sudo docker info To search images available on Docker HubVerify Docker Installation To verify the installation we can run a test container

Docker is an open-source project that allows you to easily and quickly build, test, and deploy applications. Docker organizes software into containers that contain everything the software requires to run, such as libraries, system tools, code, and runtime. Docker allows you to quickly deploy and scale applications in any environment. Developers can use the development environments on Windows, Linux, or macOS.

In this tutorial, we learn how to install Docker CE on AlmaLinux 8. The steps are also applicable to Rocky Linux 8, CentOS 8, and REHL.

Step 1: Add Repository for Docker

You can add the official Docker CE repository to your AlamLinux 8 so that we can install it without having to manually download its packages. The repository can be installed with a single command.

How to install docker on ubuntu AWS...

To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video

How to install docker on ubuntu AWS Server
$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Step 2: Run AlmaLinux/Rocky system Update

For the system to recognize the recently added Docker repository and the packages available in it, you must first run the system update, which will rebuild the AlmaLinux system repo cache.

$ sudo dnf update

You can look through the repository list to see if the newly added repo is there.

$ sudo dnf repolist -v
Step 3: Install Docker CE Engine on AlmaLinux 8 or Rocky Linux 8

Now that we've added the Docker repository to our system, we can install Docker-CE, as well as its command-line tool and containerd.io, to manage the container lifecycle of its host system using dnf.

$ sudo dnf install docker-ce docker-ce-cli containerd.io
Step 4: Start Docker

After the installation is complete, you may start the Docker service and set it to start automatically when the system boots up.

$ sudo systemctl start docker
$ sudo systemctl enable docker

To check the docker service status, type:

$ systemctl status docker

Press q to exit back to command prompt.

Step 5: Execute Docker Commands without Sudo

By default, the docker command can only be run as the root user. To avoid requiring root access to run docker commands, you can add your current system user to the Docker group, allowing you to quickly run docker command without prefixing it with sudo.

$ sudo usermod -aG docker $USER

Where $USER is the environment variable that contains your username.

Now, you can check if your user is in docker group or not.

id $USER

You can change $USER in the above command with the specific system's user if you wish to give another user the privileges to manage Docker than the present one.

You can logout and log back in to get the group membership session updated.

Step 6: Verify Docker Installation

To verify the installation we can run a test container that will access and download an image from the Docker hub.

To verify docker installation, type:

$ docker container run hello-world

Docker initially checks locally for the hello-world image, if not found download the image from Docker Hub. Once the image is downloaded, the docker daemon created a new container from that image, and the application in the container is executed, to print the message.

Using Docker Commands

Let's check few basic commands of Docker. Run docker info command to get information such as docker version installed, OS version, CPU, Kernel information, and more.

$ sudo docker info

To search images available on Docker Hub, use docker search followed by image name. For example to search ubuntu image, type:

$ docker search ubuntu

Output:

NAME                                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
 ubuntu                                                    Ubuntu is a Debian-based Linux operating sys…   12724     [OK]
 dorowu/ubuntu-desktop-lxde-vnc                            Docker image to provide HTML5 VNC interface …   563                  [OK]
 websphere-liberty                                         WebSphere Liberty multi-architecture images …   280       [OK]
 rastasheep/ubuntu-sshd                                    Dockerized SSH service, built on top of offi…   255                  [OK]
 consol/ubuntu-xfce-vnc                                    Ubuntu container with "headless" VNC session…   241                  [OK]
 ubuntu-upstart                                            DEPRECATED, as is Upstart (find other proces…   113       [OK]
 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5      ubuntu-16-nginx-php-phpmyadmin-mysql-5          50                   [OK]
 open-liberty                                              Open Liberty multi-architecture images based…   48        [OK]
 ubuntu-debootstrap                                        DEPRECATED; use "ubuntu" instead                44        [OK]
 i386/ubuntu                                               Ubuntu is a Debian-based Linux operating sys…   25

The Official column with OK shows that image the original image supported by the company behind that project.

To download the official ubuntu image, type:

$ docker pull ubuntu

To display the downloaded images, type:

$ docker images

Output:

REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
 ubuntu        latest    fb52e22af1b0   6 days ago     72.8MB
 hello-world   latest    d1165f221234   6 months ago   13.3kB

To run the ubuntu container, type:

$ docker run -it ubuntu

Output:

root@5f45c0664540:/#
Conclusion

In this tutorial, we learned how to successfully install Docker in AlmaLinux 8. The steps mentioned for installing Docker are also applicable to Rocky Linux 8, CentOS 8, and RHEL.

Ref From: linoxide
Channels:

Related articles