How To 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 -yThese 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 wgetThese 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 runcThis 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/gpgAdd the Docker CE repository using DNF configuration manager:
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoVerify the repository addition by listing configured repositories:
sudo dnf repolistYou 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-pluginThis 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 dockerVerify Docker installation and service status:
sudo systemctl status docker
docker --versionThe 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 versionThe 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 --helpThis 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-composeSet executable permissions on the binary:
sudo chmod +x /usr/local/bin/docker-composeCreate a symbolic link for system-wide access:
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-composeVerify the standalone installation:
docker-compose --versionMethod 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 -yThis 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 $USERLog out and log back in for group changes to take effect, or use the following command to apply changes immediately:
newgrp dockerTest non-root Docker access:
docker run hello-worldDocker 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"
}
EOFRestart Docker to apply configuration changes:
sudo systemctl restart dockerTesting Installation
Verify your complete Docker and Docker Compose installation with comprehensive tests:
docker run hello-world
docker compose --helpBoth 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-testCreate 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.htmlLaunch the application stack:
docker compose up -dAccess 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: trueTroubleshooting 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.repoPermission 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-engineRuntime Issues
Service startup failures often relate to port conflicts or resource limitations. Check for conflicting services:
sudo netstat -tulpn | grep :80
sudo systemctl status dockerContainer networking problems may involve firewall configuration or bridge network issues. Verify Docker network configuration:
docker network ls
docker network inspect bridgeVolume mounting issues can occur with SELinux enabled systems. Configure SELinux contexts or use appropriate volume options:
sudo setsebool -P container_manage_cgroup onPerformance Problems
Resource allocation issues manifest as slow container startup or poor application performance. Monitor system resources:
docker stats
htopDisk space problems affect container operations. Clean up unused containers and images:
docker system prune -a
docker volume pruneMemory 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-pluginFor 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-composeSystem Maintenance
Regular maintenance ensures optimal performance and security. Update AlmaLinux packages regularly:
sudo dnf updateClean up Docker resources periodically:
docker system prune --volumes
docker image prune -aImplement 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.
