Site icon CentLinux

How to install Docker Compose on CentOS 8

Share on Social Media

Learn how to install Docker Compose on CentOS 8 with this easy-to-follow guide. Get step-by-step instructions for setting up Docker Compose to manage multi-container Docker applications efficiently. #centlinux #linux #docker

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). Community Edition is free and open source and distributed under Apache License 2.0.

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

However, we can still install Docker and it’s dependencies on CentOS 8 / RHEL 8 from third party yum repositories.

In this article, we are installing Docker CE and docker-compose on CentOS 8.

How to install Docker Compose on CentOS 8

Docker vs Docker Compose

When comparing Docker and Docker Compose, it’s essential to understand that they serve different but complementary purposes in the containerization ecosystem. Here’s a breakdown of the key differences and use cases for each:

Docker

Overview:

Key Features:

Use Cases:

Docker Compose

Overview:

Key Features:

Use Cases:

Summary

Docker:

Docker Compose:

Recommended Training: Docker for the Absolute Beginner – Hands On – DevOps from Mumshad Mannambeth

Linux Server Specification

We have configured a CentOS 8 minimal installed virtual machine with following specification.

Install Docker CE Yum Repository

Connect with docker-01.recipes.com using ssh as root user.

Docker CE is available to download from Docker’s official website. However, we can also install it from Docker CE yum repository.

Add Docker CE yum repository 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 for Docker yum repository.

# dnf makecache
CentOS-8 - AppStream                            7.0 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                 2.2 kB/s | 3.9 kB     00:01
CentOS-8 - Extras                               1.7 kB/s | 1.5 kB     00:00
Docker CE Stable - x86_64                       6.5 kB/s |  21 kB     00:03
Metadata cache created.

Install Docker CE on CentOS 8

After addition of Docker CE yum repository, we can now easily install Docker CE on CentOS 8 by using a dnf command.

Docker CE requires containerd.io-1.2.2-3 (or later) package, which is blocked in CentOS 8. Therefore, we have to use an earlier version of containerd.io package.

Install docker-ce with an earlier version of containerd.io using following command.

# dnf -y install --nobest 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 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 Wed 2019-12-25 22:56:45 PKT; 30s ago
     Docs: https://docs.docker.com
 Main PID: 3139 (dockerd)
    Tasks: 17
   Memory: 66.9M
   CGroup: /system.slice/docker.service
           ââ3139 /usr/bin/dockerd -H fd://
           ââ3148 containerd --config /var/run/docker/containerd/containerd.tom>

Dec 25 22:56:45 docker-01.recipes.com dockerd[3139]: time="2019-12-25T22:56:45.>
Dec 25 22:56:45 docker-01.recipes.com systemd[1]: Started Docker Application Co>

Check Docker version.

# docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.39 (downgraded from 1.40)
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:25:41 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:06:30 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Docker CE has been installed on CentOS 8.

Create a Docker Container

Now that Docker is installed and configured, let’s put it into action by creating and running a simple container. This will help us understand how Docker containers work and how to deploy lightweight applications efficiently.

For this demonstration, we will use the official Alpine Linux image from Docker Hub. Alpine Linux is a lightweight, security-focused, and resource-efficient Linux distribution, making it an excellent choice for running containers with minimal overhead.

By pulling and running an Alpine Linux container, we can test Docker’s functionality, execute commands within the containerized environment, and explore key Docker operations such as starting, stopping, and removing containers. This hands-on approach will provide a foundational understanding of containerized workloads in Docker.

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

Pull Alpine Linux image from Docker Hub.

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

List locally available docker images.

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
alpine              latest              cc0abc535e36        23 hours ago        5.59MB

Create and run a container using Alpine Linux image.

# docker run -it --rm alpine /bin/sh
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.2
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ # uname -a
Linux c0089c037e24 4.18.0-80.11.2.el8_0.x86_64 #1 SMP Tue Sep 24 11:32:19 UTC 2019 x86_64 Linux
/ # exit

Install Docker Compose on CentOS 8

Additionally, we are installing Docker Compose on our CentOS 8 server to simplify the management of multi-container applications. With Docker Compose, we can define and configure multiple containers within a single YAML file, enabling us to start, stop, and scale entire containerized services with a single command.

This approach is particularly useful for complex applications that require multiple services, such as a web server, database, and caching system, to run together seamlessly. By using Docker Compose, we can streamline deployment, improve efficiency, and ensure a consistent environment across different development and production systems.

To begin the installation, we need to download the latest Docker Compose package from its official GitHub repository, ensuring we have the most up-to-date version with all the latest features and security patches.

# curl -L https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    546      0 --:--:--  0:00:01 --:--:--   546
100 16.2M  100 16.2M    0     0   184k      0  0:01:29  0:01:29 --:--:--  276k

Grant execute permissions to docker-compose command.

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

Check docker-compose version.

# docker-compose version
docker-compose version 1.25.1-rc1, build d92e9bee
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

We have successfully install Docker-Compose on CentOS 8.

Final Thoughts

Installing Docker Compose on CentOS 8 is a straightforward process that significantly enhances your ability to manage multi-container Docker applications. By following the steps in this guide, you can quickly set up Docker Compose and start orchestrating your containers efficiently, making your development and deployment workflows smoother.

Need expert AWS and Linux system administration? From cloud architecture to server optimization, I provide reliable and efficient solutions tailored to your needs. Hire me on Fiverr today!

FAQs

1. What is Docker Compose, and why is it used?
Docker Compose is a tool for managing multi-container applications using a simple YAML file. It allows users to define, configure, and run multiple Docker containers simultaneously, making application deployment and management easier.

2. What are the prerequisites for installing Docker Compose on CentOS 8?
Before installing Docker Compose, you need to have Docker Engine installed and running on CentOS 8. Additionally, ensure that your system is updated and has the necessary dependencies.

3. How can I verify that Docker Compose is installed correctly?
After installation, you can check the Docker Compose version using a system command. If the command returns a valid version, it means Docker Compose has been installed successfully.

4. Where is Docker Compose installed on CentOS 8?
Docker Compose is usually installed in the /usr/local/bin/ directory, making it globally accessible from the terminal. You can verify its location by checking the file path.

5. How do I update Docker Compose on CentOS 8?
To update Docker Compose, download and replace the existing binary with the latest version from the official source. Always check for updates to ensure compatibility with newer Docker features.

Exit mobile version