December 3, 2021
How to install Docker CE on Rocky Linux 8

How To Install Docker CE On Rocky Linux 8

On this article we will learn how to install Docker CE (Community Edition) and Docker Compose on Rocky Linux 8 operating system.

Introduction

The use of docker in building an application is growing rapidly. With Docker, we can manage our infrastructure in the same ways as we manage our applications. By using Docker, we can improve time for shipping, testing, and deploying code quickly, we can significantly reduce the delay between writing code and running it in production. On this article we will show you how to install Docker on Rocky Linux 8 operating system.

Docker CE (Community Edition) and Docker Compose Installation on Rocky Linux 8

Docker CE installation on Rocky LInux 8 will be explained in several sections below.

  1. Prerequisite
  2. Adding Docker Repository And Update System
  3. Installing Docker CE on Rocky Linux 8
  4. Start and Enable Docker CE Service
  5. Testing Docker CE
  6. Install Docker Compose

1. Prerequisite

Before continuing  Docker installation on Rocky Linux 8, There are several prerequisites that must be met including:

  • Rocky Linux 8 system
  • User account with sudo privillege
  • Sufficient disk space and good network access to Docker source

2. Adding Docker Repository and Update the System

On this stage, we will add official Docker CE repository on our Rocky Linux 8, so we can install Docker CE without downloading its packages manually. This task is done by typing command line : sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo.

[ramansah@otodiginet ~]$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
Adding Docker CE Repository into Rocky Linux 8 system
Adding Docker CE Repository into Rocky Linux 8 system

Once the Docker CE was added, then we have to update the Rocky Linux system, this is done so that the system can recognize a new repository that has been added, namely the Docker CE Repository. To update the system, we will type the command line : sudo dnf update.

Update Rocky Linux 8 got error message after adding Docker repo
Update Rocky Linux 8 got error message after adding Docker Repo

Unfortunately, I got the error message as shown above. The error is related to podman and container packages, even I use -- allowerrasing and --skip-broken, the error message is still appears. Finally I removed these packages that was causing the error with the command line: sudo remove podman and sudo remove containerd. then I repeat the system update as shown below.

[ramansah@otodiginet ~]$ sudo dnf update
Docker CE Stable - x86_64                                                                              20 kB/s | 3.5 kB     00:00    
Dependencies resolved.
Nothing to do.
Complete!
Update Rocky Linux system
Update Rocky Linux system

There is an not found error that appears as before.

3. Installing Docker CE on Rocky Linux 8

After adding Docker CE repository, we will install it on the system, by submitting command line : sudo dnf install -y docker-ce docker-ce-cli containerd.io.

[ramansah@otodiginet ~]$ sudo dnf install -y docker-ce docker-ce-cli containerd.io
Last metadata expiration check: 0:00:09 ago on Fri 27 Aug 2021 06:42:21 AM WIB.
Dependencies resolved.
======================================================================================================================================
 Package                            Architecture    Version                                           Repository                 Size
======================================================================================================================================
Installing:
 containerd.io                      x86_64          1.4.9-3.1.el8                                     docker-ce-stable           30 M
 docker-ce                          x86_64          3:20.10.8-3.el8                                   docker-ce-stable           22 M
 docker-ce-cli                      x86_64          1:20.10.8-3.el8                                   docker-ce-stable           29 M
Installing dependencies:
 container-selinux                  noarch          2:2.164.1-1.module+el8.4.0+643+525e162a           appstream                  51 k
 docker-ce-rootless-extras          x86_64          20.10.8-3.el8                                     docker-ce-stable          4.6 M
 docker-scan-plugin                 x86_64          0.8.0-3.el8                                       docker-ce-stable          4.2 M
 flatpak-selinux                    noarch          1.8.5-3.el8                                       appstream                  26 k
 fuse-overlayfs                     x86_64          1.6-1.module+el8.4.0+643+525e162a                 appstream                  72 k
 fuse3                              x86_64          3.2.1-12.el8                                      baseos                     49 k
 fuse3-libs                         x86_64          3.2.1-12.el8                                      baseos                     93 k
 libcgroup                          x86_64          0.41-19.el8                                       baseos                     69 k
 libslirp                           x86_64          4.3.1-1.module+el8.4.0+556+40122d08               appstream                  68 k
 selinux-policy-targeted            noarch          3.14.3-67.el8_4.1                                 baseos                     15 M
 slirp4netns                        x86_64          1.1.8-1.module+el8.4.0+556+40122d08               appstream                  50 k

Transaction Summary
======================================================================================================================================
Install  14 Packages

Total download size: 106 M
Installed size: 427 M
Downloading Packages:
(1/14): flatpak-selinux-1.8.5-3.el8.noarch.rpm                                                         66 kB/s |  26 kB     00:00    
(2/14): container-selinux-2.164.1-1.module+el8.4.0+643+525e162a.noarch.rpm                            123 kB/s |  51 kB     00:00    
(3/14): fuse-overlayfs-1.6-1.module+el8.4.0+643+525e162a.x86_64.rpm                                   160 kB/s |  72 kB     00:00    
(4/14): libslirp-4.3.1-1.module+el8.4.0+556+40122d08.x86_64.rpm                                       412 kB/s |  68 kB     00:00    
(5/14): slirp4netns-1.1.8-1.module+el8.4.0+556+40122d08.x86_64.rpm                                    351 kB/s |  50 kB     00:00    
(6/14): fuse3-3.2.1-12.el8.x86_64.rpm                                                                 399 kB/s |  49 kB     00:00    
(7/14): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                                            736 kB/s |  93 kB     00:00    
(8/14): libcgroup-0.41-19.el8.x86_64.rpm                                                              283 kB/s |  69 kB     00:00    
(9/14): selinux-policy-targeted-3.14.3-67.el8_4.1.noarch.rpm                                          1.4 MB/s |  15 MB     00:10    
(10/14): docker-ce-20.10.8-3.el8.x86_64.rpm                                                           1.3 MB/s |  22 MB     00:16    
(11/14): docker-ce-rootless-extras-20.10.8-3.el8.x86_64.rpm                                           1.2 MB/s | 4.6 MB     00:03    
(12/14): containerd.io-1.4.9-3.1.el8.x86_64.rpm                                                       1.3 MB/s |  30 MB     00:22    
(13/14): docker-scan-plugin-0.8.0-3.el8.x86_64.rpm                                                    1.5 MB/s | 4.2 MB     00:02    
(14/14): docker-ce-cli-20.10.8-3.el8.x86_64.rpm                                                       1.7 MB/s |  29 MB     00:16    
--------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                 3.6 MB/s | 106 MB     00:29     
Installing Docker CE on Rocky Linux 8
Installing Docker CE on Rocky Linux 8

The installation was completed done successfully with the message below :

Installed:
  container-selinux-2:2.164.1-1.module+el8.4.0+643+525e162a.noarch       containerd.io-1.4.9-3.1.el8.x86_64                           
  docker-ce-3:20.10.8-3.el8.x86_64                                       docker-ce-cli-1:20.10.8-3.el8.x86_64                         
  docker-ce-rootless-extras-20.10.8-3.el8.x86_64                         docker-scan-plugin-0.8.0-3.el8.x86_64                        
  flatpak-selinux-1.8.5-3.el8.noarch                                     fuse-overlayfs-1.6-1.module+el8.4.0+643+525e162a.x86_64      
  fuse3-3.2.1-12.el8.x86_64                                              fuse3-libs-3.2.1-12.el8.x86_64                               
  libcgroup-0.41-19.el8.x86_64                                           libslirp-4.3.1-1.module+el8.4.0+556+40122d08.x86_64          
  selinux-policy-targeted-3.14.3-67.el8_4.1.noarch                       slirp4netns-1.1.8-1.module+el8.4.0+556+40122d08.x86_64       

Complete!

4. Start And Enable Docker CE Service

Once Docker CE is installed then we start and enable its service by using following systemctl commands line :

  • sudo systemctl start docker
  • sudo systemctl enable docker
  • sudo systemctl status docker
[ramansah@otodiginet ~]$ sudo systemctl start docker
[sudo] password for ramansah: 
[ramansah@otodiginet ~]$ sudo systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[ramansah@otodiginet ~]$ sudo 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 Fri 2021-08-27 06:55:24 WIB; 21s ago
     Docs: https://docs.docker.com
 Main PID: 5639 (dockerd)
    Tasks: 9
   Memory: 33.3M
   CGroup: /system.slice/docker.service
           └─5639 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Aug 27 06:55:23 otodiginet dockerd[5639]: time="2021-08-27T06:55:23.375952797+07:00" level=warning msg="Your kernel does not support >
Aug 27 06:55:23 otodiginet dockerd[5639]: time="2021-08-27T06:55:23.375985234+07:00" level=warning msg="Your kernel does not support >
Aug 27 06:55:23 otodiginet dockerd[5639]: time="2021-08-27T06:55:23.376148047+07:00" level=info msg="Loading containers: start."
Aug 27 06:55:24 otodiginet dockerd[5639]: time="2021-08-27T06:55:24.445072344+07:00" level=info msg="Default bridge (docker0) is assi>
Aug 27 06:55:24 otodiginet dockerd[5639]: time="2021-08-27T06:55:24.604926449+07:00" level=info msg="Firewalld: interface docker0 alr>
Aug 27 06:55:24 otodiginet dockerd[5639]: time="2021-08-27T06:55:24.750528689+07:00" level=info msg="Loading containers: done."
Aug 27 06:55:24 otodiginet dockerd[5639]: time="2021-08-27T06:55:24.771625351+07:00" level=info msg="Docker daemon" commit=75249d8 gr>
Aug 27 06:55:24 otodiginet dockerd[5639]: time="2021-08-27T06:55:24.771733688+07:00" level=info msg="Daemon has completed initializat>
Aug 27 06:55:24 otodiginet systemd[1]: Started Docker Application Container Engine.
Aug 27 06:55:24 otodiginet dockerd[5639]: time="2021-08-27T06:55:24.791230361+07:00" level=info msg="API listen on /var/run/docker.so>
Starting Docker Service
Starting Docker Service

Then we verify the Docker version by submitting command line : docker --version.

[ramansah@otodiginet ~]$ docker --version
Docker version 20.10.8, build 3967b7d

On this step we will add a Rocky Linux User to Docker User Group to enable that user executing Docker. On this example we will use user ramansah to be a Docker group member. This job can be done by typing command line : sudo usermod -aG docker ramansah.

[ramansah@otodiginet ~]$ sudo usermod -aG docker ramansah
[ramansah@otodiginet ~]$ id ramansah
uid=1000(ramansah) gid=1000(ramansah) groups=1000(ramansah),10(wheel),974(docker)

5. Testing Docker CE

This is the last step on this article, after Docker CE installation was completed done, then we will test the Docker whether it runs normally or not. We will perform testing by running a command in docker to call the hello-world container. with the command line: sudo docker run hello-world.

[ramansah@otodiginet ~]$ sudo docker run hello-world
[sudo] password for ramansah: 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

b8dfde127a29: Pull complete 
Digest: sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
docker run hello-world
docker run hello-world

Then we will check the list of Docker images were installed on the system, by typing command line :

[ramansah@otodiginet ~]$ sudo docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    d1165f221234   5 months ago   13.3kB
list fo Docker images
Docker images list

6. Install Docker Compose On Rocky Linux 8

On this section, we will learn how to install Docker Compose on Rocky Linux 8. Docker Compose relies on Docker Engine for any meaningful work, so we have to make sure if we already have Docker Engine installed either locally or remote.

Docker Compose Installation

We will install the last stable of Docker Compose (version 1.29.2). We will use curl command line to download the Docker compose binary file, sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose.

[ramansah@otodiginet ~]$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[sudo] password for ramansah: 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   633  100   633    0     0     91      0  0:00:06  0:00:06 --:--:--   168
100 12.1M  100 12.1M    0     0   167k      0  0:01:14  0:01:14 --:--:--  396k

Change the docker-compose binary file tobe executed file by typing command line : sudo chmod+x /usr/local/bin/docker-compose.

[ramansah@otodiginet ~]$ sudo chmod +x /usr/local/bin/docker-compose

Then verify docker compose installation by querying its version, by typing command line : docker-compose --version.

[ramansah@otodiginet ~]$ docker-compose --version
docker-compose version 1.29.2, build 5becea4c
Install Docker Compose on Rocky Linux 8
Install Docker Compose on Rocky Linux 8

Conclusion

On this article we have installed the Docker CE (Community Edition) and Docker Compose on Rocky Linux 8 operating system successfully. I hope, this article can be useful for anyone who is looking for information about Docker CE installation on Rocky Linux 8.

Share this article via :

One thought on “How To Install Docker CE On Rocky Linux 8

Leave a Reply

Your email address will not be published. Required fields are marked *