Latest

Thursday, 30 June 2022

How To Install Docker CE on Rocky Linux 8

How To Install Docker CE on Rocky Linux 8

In this article, you will learn how to install Docker CE on Rocky Linux 8 or other RPM based Linux distros.

 

Table of Contents:

 

What is Docker? :

Docker is a set of Platform as a Service (PaaS) products that uses operating system level virtualizations to deliver software in the form of containers. Docker CE (Community Edition) is the strip down version of Docker EE (Enterprise Edition). Docker CE is free and open source and distributed under Apache License 2.0.

In Red Hat Enterprise Linux (RHEL) 8 / CentOS 8 or later, Support of Docker has been removed by the vendor. Whereas a new containerization platform libpod (Podman's Container Management Library) has been introduced as a replacement of Docker.

However, you can still install Docker and it’s dependencies on Rocky Linux 8 from third party yum repositories.

How To Install Docker CE on Rocky Linux 8

Recommended Online Training:Hands on With Docker & Docker Compose From a Docker Captain

Recommended eBook: Docker Deep Dive: Zero to Docker in a single book by Nigel Poulton

 

Environment Specification:

We are using a minimal Rocky Linux 8 virtual machine with following specifications.

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 2 GB
  • Storage - 20 GB
  • Operating System - Rocky Linux 8.6 (Green Obsidian)
  • Hostname – docker-01.centlinux.com
  • IP Address - 192.168.116.128 /24

 

Updating your Linux Operating System:

By using a SSH client, login to docker-01.centlinux.com as root user.

Refresh yum cache by executing following command.

# dnf makecache
Rocky Linux 8 - AppStream                       1.5 kB/s | 4.8 kB     00:03
Rocky Linux 8 - AppStream                       535 kB/s | 8.8 MB     00:16
Rocky Linux 8 - BaseOS                          1.6 kB/s | 4.3 kB     00:02
Rocky Linux 8 - BaseOS                          531 kB/s | 3.6 MB     00:06
Rocky Linux 8 - Extras                          1.2 kB/s | 3.5 kB     00:02
Rocky Linux 8 - Extras                          2.0 kB/s |  11 kB     00:05
Last metadata expiration check: 0:00:01 ago on Thu 30 Jun 2022 08:51:51 PM PKT.
Metadata cache created.

Execute following dnf command to update your Linux operating system.

# dnf update -y

If the above command updates your Linux Kernel, then reboot your operating system with newly installed Kernel.

# reboot

Verify the versions of your Linux Kernel and operating system.

# cat /etc/rocky-release
Rocky Linux release 8.6 (Green Obsidian)

# uname -r
4.18.0-372.13.1.el8_6.x86_64

 

Installing Docker CE on Rocky Linux:

Docker CE is also available to download from Docker's official website. However, there is a better way to install it from Docker CE yum repository.

For this purpose, add Docker CE yum repository by using dnf command.

# 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

Build cache of newly installed yum repositories.

# dnf makecache
Rocky Linux 8 - AppStream                       1.6 kB/s | 4.8 kB     00:02
Rocky Linux 8 - BaseOS                          1.7 kB/s | 4.3 kB     00:02
Rocky Linux 8 - Extras                          1.2 kB/s | 3.5 kB     00:02
Docker CE Stable - x86_64                        28 kB/s |  26 kB     00:00
Metadata cache created.

Now, you can easily install latest version of Docker CE, by using a dnf command.

# dnf install -y docker-ce
Last metadata expiration check: 0:00:47 ago on Thu 30 Jun 2022 09:13:23 PM PKT.
Dependencies resolved.
================================================================================
 Package                      Arch   Version             Repository        Size
================================================================================
Installing:
 docker-ce                    x86_64 3:20.10.17-3.el8    docker-ce-stable  22 M
Installing dependencies:
 checkpolicy                  x86_64 2.9-1.el8           baseos           345 k
 container-selinux            noarch 2:2.179.1-1.module+el8.6.0+971+69b94baf
                                                         appstream         57 k
 containerd.io                x86_64 1.6.6-3.1.el8       docker-ce-stable  33 M
 docker-ce-cli                x86_64 1:20.10.17-3.el8    docker-ce-stable  29 M
 docker-ce-rootless-extras    x86_64 20.10.17-3.el8      docker-ce-stable 4.7 M
 fuse-common                  x86_64 3.3.0-15.el8        baseos            21 k
 fuse-overlayfs               x86_64 1.8.2-1.module+el8.6.0+971+69b94baf
                                                         appstream         72 k
 fuse3                        x86_64 3.3.0-15.el8        baseos            53 k
 fuse3-libs                   x86_64 3.3.0-15.el8        baseos            94 k
 libcgroup                    x86_64 0.41-19.el8         baseos            69 k
 libslirp                     x86_64 4.4.0-1.module+el8.6.0+971+69b94baf
                                                         appstream         69 k
 policycoreutils-python-utils noarch 2.9-19.el8          baseos           252 k
 python3-audit                x86_64 3.0.7-2.el8.2       baseos            86 k
 python3-libsemanage          x86_64 2.9-8.el8           baseos           127 k
 python3-policycoreutils      noarch 2.9-19.el8          baseos           2.2 M
 python3-setools              x86_64 4.3.0-3.el8         baseos           623 k
 slirp4netns                  x86_64 1.1.8-2.module+el8.6.0+971+69b94baf
                                                         appstream         50 k
 tar                          x86_64 2:1.30-5.el8        baseos           837 k
Installing weak dependencies:
 docker-scan-plugin           x86_64 0.17.0-3.el8        docker-ce-stable 3.8 M
Enabling module streams:
 container-tools                     rhel8

Transaction Summary
================================================================================
Install  20 Packages

Total download size: 97 M
Installed size: 402 M
Downloading Packages:
(1/20): container-selinux-2.179.1-1.module+el8.  27 kB/s |  57 kB     00:02
(2/20): fuse-overlayfs-1.8.2-1.module+el8.6.0+9  34 kB/s |  72 kB     00:02
(3/20): libslirp-4.4.0-1.module+el8.6.0+971+69b  31 kB/s |  69 kB     00:02
(4/20): slirp4netns-1.1.8-2.module+el8.6.0+971+ 210 kB/s |  50 kB     00:00
(5/20): fuse-common-3.3.0-15.el8.x86_64.rpm     9.7 kB/s |  21 kB     00:02
(6/20): fuse3-3.3.0-15.el8.x86_64.rpm            23 kB/s |  53 kB     00:02
(7/20): checkpolicy-2.9-1.el8.x86_64.rpm        108 kB/s | 345 kB     00:03
(8/20): fuse3-libs-3.3.0-15.el8.x86_64.rpm       88 kB/s |  94 kB     00:01
(9/20): libcgroup-0.41-19.el8.x86_64.rpm         69 kB/s |  69 kB     00:00
(10/20): python3-audit-3.0.7-2.el8.2.x86_64.rpm  89 kB/s |  86 kB     00:00
(11/20): python3-libsemanage-2.9-8.el8.x86_64.r 103 kB/s | 127 kB     00:01
(12/20): policycoreutils-python-utils-2.9-19.el 148 kB/s | 252 kB     00:01
(13/20): python3-setools-4.3.0-3.el8.x86_64.rpm 217 kB/s | 623 kB     00:02
(14/20): tar-1.30-5.el8.x86_64.rpm              246 kB/s | 837 kB     00:03
(15/20): docker-ce-20.10.17-3.el8.x86_64.rpm    548 kB/s |  22 MB     00:40
(16/20): containerd.io-1.6.6-3.1.el8.x86_64.rpm 617 kB/s |  33 MB     00:54
(17/20): docker-ce-rootless-extras-20.10.17-3.e 356 kB/s | 4.7 MB     00:13
(18/20): docker-scan-plugin-0.17.0-3.el8.x86_64 379 kB/s | 3.8 MB     00:10
(19/20): docker-ce-cli-20.10.17-3.el8.x86_64.rp 792 kB/s |  29 MB     00:37
(20/20): python3-policycoreutils-2.9-19.el8.noa  25 kB/s | 2.2 MB     01:31
--------------------------------------------------------------------------------
Total                                           984 kB/s |  97 MB     01:41
Docker CE Stable - x86_64                       2.6 kB/s | 1.6 kB     00:00
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : docker-scan-plugin-0.17.0-3.el8.x86_64                1/20
  Running scriptlet: docker-scan-plugin-0.17.0-3.el8.x86_64                1/20
  Installing       : docker-ce-cli-1:20.10.17-3.el8.x86_64                 2/20
  Running scriptlet: docker-ce-cli-1:20.10.17-3.el8.x86_64                 2/20
  Installing       : fuse3-libs-3.3.0-15.el8.x86_64                        3/20
  Running scriptlet: fuse3-libs-3.3.0-15.el8.x86_64                        3/20
  Installing       : tar-2:1.30-5.el8.x86_64                               4/20
  Running scriptlet: tar-2:1.30-5.el8.x86_64                               4/20
  Installing       : python3-setools-4.3.0-3.el8.x86_64                    5/20
  Installing       : python3-libsemanage-2.9-8.el8.x86_64                  6/20
  Installing       : python3-audit-3.0.7-2.el8.2.x86_64                    7/20
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                          8/20
  Installing       : libcgroup-0.41-19.el8.x86_64                          8/20
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                          8/20
  Installing       : fuse-common-3.3.0-15.el8.x86_64                       9/20
  Installing       : fuse3-3.3.0-15.el8.x86_64                            10/20
  Installing       : fuse-overlayfs-1.8.2-1.module+el8.6.0+971+69b94baf   11/20
  Running scriptlet: fuse-overlayfs-1.8.2-1.module+el8.6.0+971+69b94baf   11/20
  Installing       : checkpolicy-2.9-1.el8.x86_64                         12/20
  Installing       : python3-policycoreutils-2.9-19.el8.noarch            13/20
  Installing       : policycoreutils-python-utils-2.9-19.el8.noarch       14/20
  Running scriptlet: container-selinux-2:2.179.1-1.module+el8.6.0+971+6   15/20
  Installing       : container-selinux-2:2.179.1-1.module+el8.6.0+971+6   15/20
  Running scriptlet: container-selinux-2:2.179.1-1.module+el8.6.0+971+6   15/20
  Installing       : containerd.io-1.6.6-3.1.el8.x86_64                   16/20
  Running scriptlet: containerd.io-1.6.6-3.1.el8.x86_64                   16/20
  Installing       : libslirp-4.4.0-1.module+el8.6.0+971+69b94baf.x86_6   17/20
  Installing       : slirp4netns-1.1.8-2.module+el8.6.0+971+69b94baf.x8   18/20
  Installing       : docker-ce-rootless-extras-20.10.17-3.el8.x86_64      19/20
  Running scriptlet: docker-ce-rootless-extras-20.10.17-3.el8.x86_64      19/20
  Installing       : docker-ce-3:20.10.17-3.el8.x86_64                    20/20
  Running scriptlet: docker-ce-3:20.10.17-3.el8.x86_64                    20/20
  Running scriptlet: container-selinux-2:2.179.1-1.module+el8.6.0+971+6   20/20
  Running scriptlet: docker-ce-3:20.10.17-3.el8.x86_64                    20/20
  Verifying        : container-selinux-2:2.179.1-1.module+el8.6.0+971+6    1/20
  Verifying        : fuse-overlayfs-1.8.2-1.module+el8.6.0+971+69b94baf    2/20
  Verifying        : libslirp-4.4.0-1.module+el8.6.0+971+69b94baf.x86_6    3/20
  Verifying        : slirp4netns-1.1.8-2.module+el8.6.0+971+69b94baf.x8    4/20
  Verifying        : checkpolicy-2.9-1.el8.x86_64                          5/20
  Verifying        : fuse-common-3.3.0-15.el8.x86_64                       6/20
  Verifying        : fuse3-3.3.0-15.el8.x86_64                             7/20
  Verifying        : fuse3-libs-3.3.0-15.el8.x86_64                        8/20
  Verifying        : libcgroup-0.41-19.el8.x86_64                          9/20
  Verifying        : policycoreutils-python-utils-2.9-19.el8.noarch       10/20
  Verifying        : python3-audit-3.0.7-2.el8.2.x86_64                   11/20
  Verifying        : python3-libsemanage-2.9-8.el8.x86_64                 12/20
  Verifying        : python3-policycoreutils-2.9-19.el8.noarch            13/20
  Verifying        : python3-setools-4.3.0-3.el8.x86_64                   14/20
  Verifying        : tar-2:1.30-5.el8.x86_64                              15/20
  Verifying        : containerd.io-1.6.6-3.1.el8.x86_64                   16/20
  Verifying        : docker-ce-3:20.10.17-3.el8.x86_64                    17/20
  Verifying        : docker-ce-cli-1:20.10.17-3.el8.x86_64                18/20
  Verifying        : docker-ce-rootless-extras-20.10.17-3.el8.x86_64      19/20
  Verifying        : docker-scan-plugin-0.17.0-3.el8.x86_64               20/20

Installed:
  checkpolicy-2.9-1.el8.x86_64
  container-selinux-2:2.179.1-1.module+el8.6.0+971+69b94baf.noarch
  containerd.io-1.6.6-3.1.el8.x86_64
  docker-ce-3:20.10.17-3.el8.x86_64
  docker-ce-cli-1:20.10.17-3.el8.x86_64
  docker-ce-rootless-extras-20.10.17-3.el8.x86_64
  docker-scan-plugin-0.17.0-3.el8.x86_64
  fuse-common-3.3.0-15.el8.x86_64
  fuse-overlayfs-1.8.2-1.module+el8.6.0+971+69b94baf.x86_64
  fuse3-3.3.0-15.el8.x86_64
  fuse3-libs-3.3.0-15.el8.x86_64
  libcgroup-0.41-19.el8.x86_64
  libslirp-4.4.0-1.module+el8.6.0+971+69b94baf.x86_64
  policycoreutils-python-utils-2.9-19.el8.noarch
  python3-audit-3.0.7-2.el8.2.x86_64
  python3-libsemanage-2.9-8.el8.x86_64
  python3-policycoreutils-2.9-19.el8.noarch
  python3-setools-4.3.0-3.el8.x86_64
  slirp4netns-1.1.8-2.module+el8.6.0+971+69b94baf.x86_64
  tar-2:1.30-5.el8.x86_64

Complete!

Enable and start Docker service.

# systemctl enable --now docker.service
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

Verify the status of Docker service.

# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor pres>
   Active: active (running) since Thu 2022-06-30 21:18:32 PKT; 16s ago
     Docs: https://docs.docker.com
 Main PID: 4460 (dockerd)
    Tasks: 7
   Memory: 35.2M
   CGroup: /system.slice/docker.service
           └─4460 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/contai>

Jun 30 21:18:30 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:30 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:30 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:31 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:31 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:32 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:32 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:32 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>
Jun 30 21:18:32 rockylinux-01.centlinux.com systemd[1]: Started Docker Applicat>
Jun 30 21:18:32 rockylinux-01.centlinux.com dockerd[4460]: time="2022-06-30T21:>

Check the version of Docker Engine.

# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:03:11 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:29 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

 

Create your First Docker Container:

Search Docker Hub for official image of Alpine Linux.

# docker search alpine --filter is-official=true
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
alpine    A minimal Docker image based on Alpine Linux…   8944      [OK]

Pull the Alpine Linux image to local Docker platform.

# docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
2408cc74d12b: Pull complete
Digest: sha256:686d8c9dfa6f3ccfc8230bc3178d23f84eeaf7e457f36f271ab1acc53015037c
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest

List the locally available Docker images.

# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
alpine       latest    e66264b98777   5 weeks ago   5.53MB

Create a Docker Container from Alpine Linux image and start /bin/sh shell, so you can execute some test commands over there.

# docker run -it --rm alpine /bin/sh
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.16.0
PRETTY_NAME="Alpine Linux v3.16"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
/ # uname -r
4.18.0-372.13.1.el8_6.x86_64
/ # exit

 

Installing Docker Compose on Rocky Linux:

You can optionally install docker-compose software, if you want to run multiple Docker containers as a single service.

Download latest version of docker-compose from GitHub by using curl command.

# curl -L https://github.com/docker/compose/releases/download/v2.6.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 24.5M  100 24.5M    0     0  1037k      0  0:00:24  0:00:24 --:--:-- 1252k

Grant execution permissions to docker-compose file.

# chmod +x /usr/local/bin/docker-compose

Execute docker-compose command to check it's version.

# docker-compose version
Docker Compose version v2.6.1

 

Conclusion:

In this guide, you have successfully learned how to install Docker CE on Rocky Linux 8 or other RPM based Linux distros.

If you find this article useful? Consider supporting us by Buy Me A Coffee


No comments:

Post a Comment

© 2022 CentLinux. All Rights Reserved.