AlmaLinuxRHEL Based

How To Install Docker Compose on AlmaLinux 10

Install Docker Compose on AlmaLinux 10

In this tutorial, we will show you how to install Docker Compose on AlmaLinux 10. Docker Compose has become an essential tool for modern containerized application development and deployment. As enterprises increasingly adopt containerization strategies, AlmaLinux 10 emerges as a robust, enterprise-grade platform that perfectly complements Docker’s capabilities. This comprehensive guide walks you through every step of installing Docker Compose on AlmaLinux 10, ensuring you can efficiently orchestrate multi-container applications with confidence.

Whether you’re a system administrator managing production environments or a developer setting up local development workflows, this tutorial provides multiple installation methods, troubleshooting solutions, and best practices. By the end of this guide, you’ll have a fully functional Docker Compose setup ready for production workloads.

Understanding Docker Compose and AlmaLinux 10

What is Docker Compose?

Docker Compose is a powerful orchestration tool that simplifies the management of multi-container Docker applications. Unlike traditional container management approaches that require complex command-line operations, Docker Compose uses declarative YAML configuration files to define entire application stacks. This approach enables developers to specify services, networks, volumes, and dependencies in a single, version-controlled file.

The tool excels at managing complex applications with multiple interconnected services. For instance, a typical web application might require a web server, database, cache layer, and background workers. Docker Compose allows you to define all these components in one file and manage them collectively with simple commands like docker compose up and docker compose down.

AlmaLinux 10 Overview

AlmaLinux 10 represents the latest evolution of enterprise Linux distributions, serving as a community-driven successor to CentOS. Built on Red Hat Enterprise Linux foundations, AlmaLinux provides exceptional stability, security, and performance characteristics essential for production environments. The distribution offers long-term support, making it ideal for enterprise deployments where consistency and reliability are paramount.

The platform’s architecture delivers outstanding container technology compatibility, with optimized kernel features and resource management capabilities. AlmaLinux 10 includes enhanced security features, improved container isolation, and better performance optimization compared to previous versions.

Prerequisites and System Requirements

Hardware Requirements

Before installing Docker Compose on AlmaLinux 10, ensure your system meets the minimum hardware specifications. Your server should have at least 2GB of RAM, though 4GB or more is recommended for optimal performance. The system requires a minimum of 2 CPU cores, with x86_64 or ARM64 architecture support.

Storage requirements depend on your intended usage, but allocate at least 10GB of free disk space for Docker images and containers. For production environments, consider using SSD storage for improved I/O performance. Network connectivity is essential for downloading Docker images and packages from repositories.

Software Prerequisites

Verify your AlmaLinux 10 installation is current and functional. Check the kernel version using uname -r to ensure you’re running kernel version 3.10 or higher, which is required for Docker’s advanced features. Administrative access through sudo privileges is mandatory for installation and configuration tasks.

Ensure your system has a reliable internet connection for downloading packages and Docker images. If you’re working in a corporate environment, verify that firewall rules allow access to Docker registries and package repositories.

Network and Security Considerations

Configure your firewall to allow Docker’s default communication ports. Docker typically uses port 2376 for secure daemon communication and various ports for container services. SELinux configurations on AlmaLinux may require adjustments to allow container operations without compromising security.

Consider network topology requirements if you plan to use Docker Swarm or external container registries. Some corporate environments require proxy configurations for internet access, which may need additional Docker daemon configuration.

System Preparation and Initial Setup

Updating the System

Begin by updating your AlmaLinux 10 system to ensure all packages are current. The DNF package manager provides efficient package management with dependency resolution and security updates. Execute the following commands to refresh repositories and upgrade existing packages:

sudo dnf --refresh update
sudo dnf upgrade -y

These commands update package metadata and install the latest versions of all installed packages. The process may take several minutes depending on your system’s current state and available updates. Reboot your system if kernel updates were installed to ensure all changes take effect.

Installing Essential Tools

Install prerequisite packages that Docker installation requires. The yum-utils package provides repository management utilities, while device-mapper-persistent-data and lvm2 support Docker’s storage drivers:

sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 curl wget

These tools are essential for Docker’s advanced storage features and repository management. The curl and wget utilities facilitate downloading Docker Compose binaries and other required files.

Removing Conflicting Packages

AlmaLinux systems often include Podman and Buildah pre-installed, which can create conflicts with Docker installation. Remove these packages to ensure a clean Docker installation:

sudo dnf remove -y podman buildah runc

This step prevents package conflicts and ensures Docker has exclusive control over container runtime operations. If you need to preserve existing containers, back them up before removing these packages.

Installing Docker Engine

Adding Docker Repository

Docker packages aren’t available in AlmaLinux default repositories, requiring you to add the official Docker Community Edition repository. Since AlmaLinux is CentOS-compatible, use the CentOS Docker repository configuration.

First, import the Docker GPG key to verify package authenticity:

sudo rpm --import https://download.docker.com/linux/centos/gpg

Add the Docker CE repository using DNF configuration manager:

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

Verify the repository addition by listing configured repositories:

sudo dnf repolist

You should see the Docker CE repository listed among your configured package sources.

Docker Installation Process

Install Docker Engine and its dependencies using DNF. The installation includes Docker CE (Community Edition), Docker CLI, and containerd runtime:

sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

This command installs the complete Docker ecosystem including the newer Docker Compose plugin, which is the recommended approach for new installations. The process downloads approximately 80-100MB of packages and automatically resolves dependencies.

Docker Service Configuration

Configure Docker service to start automatically on system boot and start the service immediately:

sudo systemctl start docker
sudo systemctl enable docker

Verify Docker installation and service status:

sudo systemctl status docker
docker --version

The service should show as “active (running)” and the version command should display the installed Docker version.

Installing Docker Compose

Method 1: Docker Compose Plugin (Recommended)

The Docker Compose plugin represents the modern approach to Docker Compose installation. This method integrates Compose functionality directly into the Docker CLI, providing better performance and tighter integration. If you installed Docker using the previous section’s commands, the plugin is already installed.

Verify the plugin installation:

docker compose version

The plugin-based installation offers several advantages: automatic updates with Docker, improved performance, and seamless CLI integration. Commands use docker compose instead of the legacy docker-compose syntax.

Test the installation with a simple container:

docker compose --help

This should display comprehensive help information for Docker Compose commands.

Method 2: Standalone Docker Compose Installation

For environments requiring the standalone Docker Compose binary, download it directly from GitHub. This method provides more flexibility but requires manual updates:

sudo curl -L "https://github.com/docker/compose/releases/download/v2.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Set executable permissions on the binary:

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

Create a symbolic link for system-wide access:

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Verify the standalone installation:

docker-compose --version

Method 3: Using Package Manager

Some environments prefer package manager installation for easier maintenance. While not officially supported for AlmaLinux 10, you can use EPEL repositories:

sudo dnf install epel-release -y
sudo dnf install docker-compose -y

This method may provide older versions but offers automatic updates through the system package manager. Check version compatibility before using this approach in production environments.

Post-Installation Configuration

User Group Management

Add your user account to the Docker group to enable non-root Docker usage. This configuration improves security by avoiding unnecessary root privileges:

sudo usermod -aG docker $USER

Log out and log back in for group changes to take effect, or use the following command to apply changes immediately:

newgrp docker

Test non-root Docker access:

docker run hello-world

Docker Daemon Configuration

Customize Docker daemon settings by creating a configuration file. Create /etc/docker/daemon.json for advanced configuration:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<EOF
{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "10m",
        "max-file": "3"
    },
    "storage-driver": "overlay2"
}
EOF

Restart Docker to apply configuration changes:

sudo systemctl restart docker

Testing Installation

Verify your complete Docker and Docker Compose installation with comprehensive tests:

docker run hello-world
docker compose --help

Both commands should execute successfully without errors, confirming proper installation and configuration.

Creating Your First Docker Compose Project

Basic Docker Compose File Structure

Docker Compose uses YAML syntax to define multi-container applications. Create a test directory and compose file:

mkdir ~/docker-compose-test
cd ~/docker-compose-test

Create a basic docker-compose.yml file:

version: '3.8'
services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html
  
  database:
    image: postgres:13
    environment:
      POSTGRES_DB: testdb
      POSTGRES_USER: testuser
      POSTGRES_PASSWORD: testpass
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Sample Multi-Container Application

This example demonstrates a web server with database backend. Create the HTML directory and sample content:

mkdir html
echo "<h1>Hello from Docker Compose on AlmaLinux 10!</h1>" > html/index.html

Launch the application stack:

docker compose up -d

Access the web server at http://localhost:8080 to verify functionality. The -d flag runs containers in detached mode.

Advanced Configuration and Best Practices

Performance Optimization

Configure resource limits and reservations to optimize performance. Update your docker-compose.yml with resource constraints:

services:
  web:
    image: nginx:alpine
    deploy:
      resources:
        limits:
          memory: 512M
          cpus: '0.5'
        reservations:
          memory: 256M
          cpus: '0.25'

Use the overlay2 storage driver for optimal performance on AlmaLinux 10. Configure Docker daemon settings to use efficient storage backends and optimize network performance.

Security Hardening

Implement security best practices by using non-root users in containers, scanning images for vulnerabilities, and implementing network isolation. Configure firewall rules to restrict container network access and use Docker secrets for sensitive data management.

Create isolated networks for different application components:

networks:
  frontend:
    driver: bridge
  backend:
    driver: bridge
    internal: true

Troubleshooting Common Issues

Installation Problems

Repository access issues often stem from firewall restrictions or DNS problems. Verify internet connectivity and DNS resolution:

nslookup download.docker.com
curl -I https://download.docker.com/linux/centos/docker-ce.repo

Permission denied errors typically indicate insufficient user privileges. Ensure your user account has sudo access and proper group membership.

Package conflicts may occur if previous Docker installations exist. Remove all Docker-related packages and start with a clean installation:

sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

Runtime Issues

Service startup failures often relate to port conflicts or resource limitations. Check for conflicting services:

sudo netstat -tulpn | grep :80
sudo systemctl status docker

Container networking problems may involve firewall configuration or bridge network issues. Verify Docker network configuration:

docker network ls
docker network inspect bridge

Volume mounting issues can occur with SELinux enabled systems. Configure SELinux contexts or use appropriate volume options:

sudo setsebool -P container_manage_cgroup on

Performance Problems

Resource allocation issues manifest as slow container startup or poor application performance. Monitor system resources:

docker stats
htop

Disk space problems affect container operations. Clean up unused containers and images:

docker system prune -a
docker volume prune

Memory usage optimization requires proper container resource limits and host system tuning. Configure swap appropriately and monitor memory consumption.

Maintenance and Updates

Keeping Docker Compose Updated

Update the Docker Compose plugin through Docker package updates:

sudo dnf update docker-compose-plugin

For standalone installations, download newer versions manually:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

System Maintenance

Regular maintenance ensures optimal performance and security. Update AlmaLinux packages regularly:

sudo dnf update

Clean up Docker resources periodically:

docker system prune --volumes
docker image prune -a

Implement log rotation to manage disk space usage. Configure logrotate for Docker logs and monitor system resource consumption.

Congratulations! You have successfully installed Docker Compose. Thanks for using this tutorial for installing the Docker Compose on your AlmaLinux OS 10 system. For additional or useful information, we recommend you check the official Docker website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button