How to install Docker CE on Rocky Linux 8

Share on Social Media

Learn how to install Docker CE on Rocky Linux 8 with this step-by-step guide. Follow along to set up Docker’s community edition and start containerizing your applications efficiently. #centlinux #linux #docker

What is Docker CE?

Docker CE, or Docker Community Edition, is a free and open-source version of the Docker platform. It provides the essential tools for building, shipping, and running containerized applications. Docker CE includes the Docker Engine, which is the runtime environment for containers, along with command-line tools and utilities for managing containers and images.

Key features of Docker CE include:

  1. Containerization: Docker CE allows you to package your applications and their dependencies into lightweight, portable containers that can run consistently across different environments.
  2. Isolation: Containers created with Docker CE offer process isolation, ensuring that applications running within them do not interfere with each other or the host system.
  3. Resource Efficiency: Docker CE optimizes resource utilization by sharing the host system’s kernel among containers, enabling efficient use of CPU, memory, and storage resources.
  4. Portability: Docker CE containers are portable across various platforms and cloud environments, making it easy to deploy applications consistently across development, testing, and production environments.
  5. Version Control: Docker CE allows you to version control your application’s containers and images, enabling collaboration among team members and facilitating rollbacks to previous versions if needed.
  6. Orchestration: While Docker CE itself provides basic container management capabilities, it can be integrated with orchestration tools like Docker Swarm or Kubernetes for managing containerized applications at scale.

Overall, Docker CE simplifies the process of building, deploying, and managing applications using containers, making it a popular choice for developers, DevOps teams, and organizations seeking agile and efficient software delivery practices.

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.

What is Docker Compose?

Docker Compose is a tool provided by Docker that simplifies the process of defining and running multi-container Docker applications. It allows you to use a YAML file to configure the services, networks, and volumes required for your application and then spin up all the containers with a single command.

Here are the key features and components of Docker Compose:

  1. YAML Configuration: Docker Compose uses a simple YAML file to define the services that make up your application, along with their configuration options, dependencies, volumes, and networking requirements.
  2. Multi-Container Applications: With Docker Compose, you can define and manage multi-container applications, where each service runs in its own container. This makes it easy to decompose complex applications into smaller, manageable components.
  3. Service Dependencies: Docker Compose allows you to specify dependencies between services, ensuring that containers are started in the correct order and that they can communicate with each other as needed.
  4. Volume and Network Configuration: You can define volumes and networks for your Docker Compose services directly in the YAML file, making it easy to manage data persistence and network communication between containers.
  5. Environment Variables and Secrets: Docker Compose supports the use of environment variables and secrets, allowing you to parameterize your configuration and securely pass sensitive information to your containers.
  6. Lifecycle Management: Docker Compose provides commands for managing the lifecycle of your application, including starting, stopping, and restarting containers, as well as scaling services up or down to accommodate changes in demand.

Overall, Docker Compose streamlines the process of working with Docker containers, especially for development and testing environments, by providing a simple and consistent way to define, configure, and manage multi-container applications.

Docker.io vs Docker-CE

Docker.io and Docker CE (Community Edition) are closely related but refer to slightly different aspects of the Docker ecosystem:

  1. Docker.io: Docker.io refers to the core Docker software and the Docker Engine, which is the runtime environment for Docker containers. It encompasses the fundamental tools and components needed to create, manage, and run containers on a host system. Docker.io is the upstream open-source project that forms the basis for Docker CE and Docker EE (Enterprise Edition).
  2. Docker CE (Community Edition): Docker CE is a specific distribution of Docker that is geared towards individual developers, small teams, and community contributors. It includes the Docker Engine, as well as additional tools and utilities for building, shipping, and running containers. Docker CE is free to use and is distributed under an open-source license.

In summary, Docker.io represents the broader Docker ecosystem, including the core Docker software, while Docker CE is a specific edition of Docker tailored for community users and developers, providing an easy-to-use platform for containerization.

Recommended eBook: Docker Deep Dive: Zero to Docker in a single book (PAID LINK) by Nigel Poulton
Recommended Online Training: Docker & Kubernetes: The Practical Guide [AWS Platform]

5242980 5479 3show?id=oLRJ54lcVEg&offerid=1486687.391975262644213658097558&bids=1486687

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

Read Also: How to run Keycloak Docker Container

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

How to install Docker CE on Rocky Linux 8

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

For this purpose, add Docker 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 Docker CE on Linux by using a 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.

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:>

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

You have successfully install Docker CE on Rocky Linux 8.

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

How to install 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

Read Also: Setup a Private Docker Registry in Rocky Linux 8

Final Thoughts

Installing Docker CE on Rocky Linux 8 is a straightforward process that empowers you to leverage containerization for your applications. If you need personalized assistance or a customized setup, feel free to explore my services on Fiverr.

Leave a Comment