How to Install Docker in Linux CentOS 8

Posted on

Introduction

This article will provide information about how to install podman in Linux CentOS 8. Actually, the installation exist in a running virtual server. The virtual server is using Linux CentOS 8 as its operating system. Furthermore, the virtual server is running in a VirtualBox application. The reference for installing docker in Linux CentOS 8 is in this link. It is an article with the title of ‘Install Docker and Manage it with Portainer on CENTOS 8 / RHEL 8’.

Docker Installation Step

So, there are several steps for installing docker. The following steps actually refers to the article with the title of ‘Install Docker and Manage it with Portainer on CENTOS 8 / RHEL 8’ in this link. But in this article, it will perform to execute it with a few output display of it. The steps are in the following sequence :

  1. Install a repository which is containing the docker packages. Actually, by default there are no docker packages available on CentOS 8 repositories. So, execute following command in the command line to enable Docker CE repository :

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

    The real execution exist in the following output :

    [root@10 ~]# 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
    [root@10 ~]#
    
  2. The following after just install the docker tool by executing the following command pattern :

    dnf install docker-ce --nobest -y

    The execution using the above command exist as follows :

    [root@10 ~]# dnf install docker-ce --nobest -y
    Docker CE Stable - x86_64                                                                12 kB/s |  11 kB     00:00
    Dependencies resolved.
    ======================================================================================================================== Package                        Arch        Version                                         Repository             Size
    ========================================================================================================================Installing:
     docker-ce                      x86_64      3:20.10.5-3.el8                                 docker-ce-stable       27 M
    Installing dependencies:
     container-selinux              noarch      2:2.155.0-1.module_el8.3.0+699+d61d9c41         appstream              51 k
     containerd.io                  x86_64      1.4.4-3.1.el8                                   docker-ce-stable       33 M
     docker-ce-cli                  x86_64      1:20.10.5-3.el8                                 docker-ce-stable       33 M
     docker-ce-rootless-extras      x86_64      20.10.5-3.el8                                   docker-ce-stable      9.1 M
     fuse-common                    x86_64      3.2.1-12.el8                                    baseos                 21 k
     fuse-overlayfs                 x86_64      1.3.0-2.module_el8.3.0+699+d61d9c41             appstream              72 k
     fuse3                          x86_64      3.2.1-12.el8                                    baseos                 50 k
     fuse3-libs                     x86_64      3.2.1-12.el8                                    baseos                 94 k
     libcgroup                      x86_64      0.41-19.el8                                     baseos                 70 k
     libslirp                       x86_64      4.3.1-1.module_el8.3.0+475+c50ce30b             appstream              69 k
     slirp4netns                    x86_64      1.1.8-1.module_el8.3.0+699+d61d9c41             appstream              51 k
    Enabling module streams:
     container-tools                            rhel8
    
    Transaction Summary
    ========================================================================================================================Install  12 Packages
    
    Total download size: 103 M
    Installed size: 425 M
    Downloading Packages:
    (1/12): fuse-overlayfs-1.3.0-2.module_el8.3.0+699+d61d9c41.x86_64.rpm                    62 kB/s |  72 kB     00:01
    (2/12): container-selinux-2.155.0-1.module_el8.3.0+699+d61d9c41.noarch.rpm               43 kB/s |  51 kB     00:01
    (3/12): slirp4netns-1.1.8-1.module_el8.3.0+699+d61d9c41.x86_64.rpm                      1.3 MB/s |  51 kB     00:00
    (4/12): libslirp-4.3.1-1.module_el8.3.0+475+c50ce30b.x86_64.rpm                          54 kB/s |  69 kB     00:01
    (5/12): fuse-common-3.2.1-12.el8.x86_64.rpm                                              22 kB/s |  21 kB     00:00
    (6/12): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                              101 kB/s |  94 kB     00:00
    (7/12): fuse3-3.2.1-12.el8.x86_64.rpm                                                    49 kB/s |  50 kB     00:01
    (8/12): libcgroup-0.41-19.el8.x86_64.rpm                                                945 kB/s |  70 kB     00:00
    (9/12): docker-ce-20.10.5-3.el8.x86_64.rpm                                              360 kB/s |  27 MB     01:15
    (10/12): docker-ce-rootless-extras-20.10.5-3.el8.x86_64.rpm                             282 kB/s | 9.1 MB     00:33
    (11/12): docker-ce-cli-20.10.5-3.el8.x86_64.rpm                                         309 kB/s |  33 MB     01:49
    (12/12): containerd.io-1.4.4-3.1.el8.x86_64.rpm                                         299 kB/s |  33 MB     01:54
    ------------------------------------------------------------------------------------------------------------------------Total                                                                                   893 kB/s | 103 MB     01:57
    warning: /var/cache/dnf/docker-ce-stable-fa9dc42ab4cec2f4/packages/containerd.io-1.4.4-3.1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
    Docker CE Stable - x86_64                                                               2.9 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
      Running scriptlet: container-selinux-2:2.155.0-1.module_el8.3.0+699+d61d9c41.noarch                              1/12
      Installing       : container-selinux-2:2.155.0-1.module_el8.3.0+699+d61d9c41.noarch                              1/12
      Running scriptlet: container-selinux-2:2.155.0-1.module_el8.3.0+699+d61d9c41.noarch                              1/12
      Installing       : containerd.io-1.4.4-3.1.el8.x86_64                                                            2/12
      Running scriptlet: containerd.io-1.4.4-3.1.el8.x86_64                                                            2/12
      Installing       : docker-ce-cli-1:20.10.5-3.el8.x86_64                                                          3/12
      Running scriptlet: docker-ce-cli-1:20.10.5-3.el8.x86_64                                                          3/12
      Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                  4/12
      Installing       : libcgroup-0.41-19.el8.x86_64                                                                  4/12
      Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                  4/12
      Installing       : fuse3-libs-3.2.1-12.el8.x86_64                                                                5/12
      Running scriptlet: fuse3-libs-3.2.1-12.el8.x86_64                                                                5/12
      Installing       : fuse-common-3.2.1-12.el8.x86_64                                                               6/12
      Installing       : fuse3-3.2.1-12.el8.x86_64                                                                     7/12
      Installing       : fuse-overlayfs-1.3.0-2.module_el8.3.0+699+d61d9c41.x86_64                                     8/12
      Running scriptlet: fuse-overlayfs-1.3.0-2.module_el8.3.0+699+d61d9c41.x86_64                                     8/12
      Installing       : libslirp-4.3.1-1.module_el8.3.0+475+c50ce30b.x86_64                                           9/12
      Installing       : slirp4netns-1.1.8-1.module_el8.3.0+699+d61d9c41.x86_64                                       10/12
      Installing       : docker-ce-rootless-extras-20.10.5-3.el8.x86_64                                               11/12
      Running scriptlet: docker-ce-rootless-extras-20.10.5-3.el8.x86_64                                               11/12
      Installing       : docker-ce-3:20.10.5-3.el8.x86_64                                                             12/12
      Running scriptlet: docker-ce-3:20.10.5-3.el8.x86_64                                                             12/12
      Running scriptlet: container-selinux-2:2.155.0-1.module_el8.3.0+699+d61d9c41.noarch                             12/12
      Running scriptlet: docker-ce-3:20.10.5-3.el8.x86_64                                                             12/12
      Verifying        : container-selinux-2:2.155.0-1.module_el8.3.0+699+d61d9c41.noarch                              1/12
      Verifying        : fuse-overlayfs-1.3.0-2.module_el8.3.0+699+d61d9c41.x86_64                                     2/12
      Verifying        : libslirp-4.3.1-1.module_el8.3.0+475+c50ce30b.x86_64                                           3/12
      Verifying        : slirp4netns-1.1.8-1.module_el8.3.0+699+d61d9c41.x86_64                                        4/12
      Verifying        : fuse-common-3.2.1-12.el8.x86_64                                                               5/12
      Verifying        : fuse3-3.2.1-12.el8.x86_64                                                                     6/12
      Verifying        : fuse3-libs-3.2.1-12.el8.x86_64                                                                7/12
      Verifying        : libcgroup-0.41-19.el8.x86_64                                                                  8/12
      Verifying        : containerd.io-1.4.4-3.1.el8.x86_64                                                            9/12
      Verifying        : docker-ce-3:20.10.5-3.el8.x86_64                                                             10/12
      Verifying        : docker-ce-cli-1:20.10.5-3.el8.x86_64                                                         11/12
      Verifying        : docker-ce-rootless-extras-20.10.5-3.el8.x86_64                                               12/12
    
    Installed:
      container-selinux-2:2.155.0-1.module_el8.3.0+699+d61d9c41.noarch
      containerd.io-1.4.4-3.1.el8.x86_64
      docker-ce-3:20.10.5-3.el8.x86_64
      docker-ce-cli-1:20.10.5-3.el8.x86_64
      docker-ce-rootless-extras-20.10.5-3.el8.x86_64
      fuse-common-3.2.1-12.el8.x86_64
      fuse-overlayfs-1.3.0-2.module_el8.3.0+699+d61d9c41.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.3.0+475+c50ce30b.x86_64
      slirp4netns-1.1.8-1.module_el8.3.0+699+d61d9c41.x86_64
    
    Complete!
    [root@10 ~]#
    
    
  3. Soon after, start preparing the docker service as the execution of the following commands :

    [root@10 ~]# systemctl start docker
    [root@10 ~]# systemctl enable docker
    Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
    [root@10 ~]# 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 Wed 2021-04-07 22:39:55 EDT; 9s ago
         Docs: https://docs.docker.com
     Main PID: 48641 (dockerd)
        Tasks: 8
       Memory: 43.6M
       CGroup: /system.slice/docker.service
               └─48641 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    
    Apr 07 22:39:54 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:54.208717163-04:00" level=warning msg="Your kernel does not support cgroup blkio weight"
    Apr 07 22:39:54 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:54.208765774-04:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
    Apr 07 22:39:54 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:54.209150894-04:00" level=info msg="Loading containers: start."
    Apr 07 22:39:55 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:55.071169308-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16.>
    Apr 07 22:39:55 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:55.402248397-04:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
    Apr 07 22:39:55 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:55.653789852-04:00" level=info msg="Loading containers: done."
    Apr 07 22:39:55 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:55.674155973-04:00" level=info msg="Docker daemon" commit=363e9a8 graphdriver(s)=overlay2 version=20.10.5
    Apr 07 22:39:55 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:55.674277927-04:00" level=info msg="Daemon has completed initialization"
    Apr 07 22:39:55 10.0.2.15 systemd[1]: Started Docker Application Container Engine.
    Apr 07 22:39:55 10.0.2.15 dockerd[48641]: time="2021-04-07T22:39:55.713425886-04:00" level=info msg="API listen on /var/run/docker.sock"
    lines 1-20/20 (END)
    
    [root@10 ~]#
    
  4. Finally the docker service has started. But actually, given the state of the docker installation, it is not a standard requirement for starting the service before in order to run a container. Aside from that, the following is the execution of the command for running a container as an example in the command line :

    [root@10 ~]# docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    b8dfde127a29: Pull complete
    Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
    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/
    
    [root@10 ~]#
    

Leave a Reply