Latest

Tuesday, 8 November 2022

How to install Docker CE on Rocky Linux 9

How to install Docker CE on Rocky Linux 9

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

 

Table of Contents:

     

    What is Docker?:

    Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first started in 2013 and is developed by Docker, Inc. (Source: Wikipedia)

    Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.

    Docker can package an application and its dependencies in a virtual container that can run on any Linux, Windows, or macOS computer. This enables the application to run in a variety of locations, such as on-premises, in public (see decentralized computing, distributed computing, and cloud computing) or private cloud. When running on Linux, Docker uses the resource isolation features of the Linux kernel (such as cgroups and kernel namespaces) and a union-capable file system (such as OverlayFS) to allow containers to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines. Docker on macOS uses a Linux virtual machine to run the containers.

    How to install Docker CE on Rocky Linux 9

    Read Also:


    Environment Specification:

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

    • CPU - 3.4 Ghz (2 cores)
    • Memory - 2 GB
    • Storage - 20 GB
    • Operating System - Rocky Linux release 9.0 (Blue Onyx)
    • Hostname - docker-01.centlinux.com
    • IP Address - 192.168.116.131/24

     

    Preparing your Docker Host:

    By using a ssh client, login to your Rocky Linux server as root user.

    Set a FQDN (Fully Qualified Domain Name) hostname for your Docker Host machine.

    # hostnamectl set-hostname docker-01.centlinux.com

    Refresh your cache for enabled yum repositories.

    # dnf makecache --refresh
    Rocky Linux 9 - BaseOS                          302 kB/s | 1.7 MB     00:05
    Rocky Linux 9 - AppStream                       638 kB/s | 6.0 MB     00:09
    Rocky Linux 9 - Extras                          961  B/s | 2.9 kB     00:03
    Metadata cache created.

    Execute following dnf command to update software packages in your Docker Server.

    # dnf update -y

    The above may updates the software packages related to Linux Kernel. In such case, you should reboot your Linux operating system with latest Linux Kernel before installing Docker CE software.

    # reboot

    After reboot, Check the versions of Linux Kernel and Operating System.

    # cat /etc/rocky-release
    Rocky Linux release 9.0 (Blue Onyx)
    
    # uname -r
    5.14.0-70.30.1.el9_0.x86_64

     

    Installing Docker Yum Repository:

    Community's most favorite containerization software is available via Docker's Official Yum Repository.

    Execute following command to download and install Docker Yum repository on your Rocky Linux server.

    # 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

    You have added a new yum repository, therefore, rebuild your yum cache again.

    # dnf makecache
    Docker CE Stable - x86_64                       5.6 kB/s |  12 kB     00:02
    Rocky Linux 9 - BaseOS                          1.6 kB/s | 3.6 kB     00:02
    Rocky Linux 9 - AppStream                       1.4 kB/s | 3.6 kB     00:02
    Rocky Linux 9 - Extras                          845  B/s | 2.9 kB     00:03
    Metadata cache created.

     

    Installing Docker CE Software:

    You have added Docker yum repository in your Linux server. Now you can easily install your Containerization software by using dnf command.

    # dnf install -y docker-ce

    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.

    Check the status of Docker service for any errors.

    # systemctl status docker.service
    ● docker.service - Docker Application Container Engine
         Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor pr>
         Active: active (running) since Sun 2022-11-06 04:00:18 CST; 11s ago
    TriggeredBy: ● docker.socket
           Docs: https://docs.docker.com
       Main PID: 2728 (dockerd)
          Tasks: 9
         Memory: 28.3M
            CPU: 450ms
         CGroup: /system.slice/docker.service
                 └─2728 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/cont>
    
    Nov 06 04:00:18 docker-01.centlinux.com dockerd[2728]: time="2022-11-06T04:00:1>
    Nov 06 04:00:18 docker-01.centlinux.com systemd[1]: Started Docker Application >

    Verify that the Docker command is working fine by querying the version of you Containerization software.

    # docker version
    Client: Docker Engine - Community
     Version:           20.10.21
     API version:       1.41
     Go version:        go1.18.7
     Git commit:        baeda1f
     Built:             Tue Oct 25 18:02:16 2022
     OS/Arch:           linux/amd64
     Context:           default
     Experimental:      true
    
    Server: Docker Engine - Community
     Engine:
      Version:          20.10.21
      API version:      1.41 (minimum version 1.12)
      Go version:       go1.18.7
      Git commit:       3056208
      Built:            Tue Oct 25 18:00:01 2022
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.6.9
      GitCommit:        1c90a442489720eec95342e1789ee8a5e1b9536f
     runc:
      Version:          1.1.4
      GitCommit:        v1.1.4-0-g5fd4c4d
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

     

    Examples of Docker Command Usage:

    Search Docker Hub for Alpine Linux images, you can use the --filter switch to list only Official images.

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

    Pull Alpine Linux image from Docker Hub.

    # docker pull alpine
    Using default tag: latest
    latest: Pulling from library/alpine
    213ec9aee27d: Pull complete
    Digest: sha256:bc41182d7ef5ffc53a40b044e725193bc10142a1243f395ee852a8d9730fc2ad
    Status: Downloaded newer image for alpine:latest
    docker.io/library/alpine:latest

    List down the locally available container images on your Docker Host.

    # docker images
    REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
    alpine       latest    9c6f07244728   2 months ago   5.54MB

    Create a Container from Alpine Linux image, acquire a shell and execute some test commands thereon.

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

     

    Conclusion:

    In this configuration guide, you have learned how to install Docker CE on Rocky Linux 9 or other RPM based Linux distros. Docker: Up & Running: Shipping Reliable Containers in Production by Sean P. Kane & Karl Matthias.

    If you find this article useful? Don't you mind support us by Buy Me A Coffee


    No comments:

    Post a Comment

    © 2022 CentLinux. All Rights Reserved.