Deploying Docker and Docker Compose on CentOS/AlmaLinux Environments

On RHEL-based distributions like AlmaLinux and CentOS Stream, Docker is not included in the default repositories. Instead, these systems favor podman. However, for many production workflows on a Hovixa VPS, the standard Docker Engine is still preferred for its extensive ecosystem and tool compatibility. This guide walks through the technical process of adding the official Docker repositories and configuring the daemon.

1. Cleaning Conflict Packages

Before proceeding, you must remove podman and buildah, as they provide conflicting binaries for container management. Failure to do this can lead to "transaction check" errors during the Docker installation.

# Remove conflicting container tools
sudo dnf remove -y podman buildah

# Install the dnf-plugins-core for repository management
sudo dnf install -y dnf-plugins-core
    

2. Repository Configuration

We utilize the official Docker CentOS repository, which is fully compatible with AlmaLinux. This ensures your Hovixa VPS receives the most secure, stable version of the Docker Engine.

[Image of the Docker Engine architecture: Client-Server communication via REST API]

# Add the official Docker CE repository
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    

3. Installing Docker Engine and Compose

With the repository active, install the Docker Engine components. This includes the core daemon, the CLI, and the docker-compose-plugin.

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

4. Service Lifecycle and Permissions

Unlike Debian-based systems, the Docker service is not started or enabled automatically upon installation on RHEL-based OSs. You must manage the service state using systemctl.

# Start and enable Docker on boot
sudo systemctl enable --now docker

# Optional: Add current user to the docker group to avoid sudo
sudo usermod -aG docker $USER
    

5. Technical Configuration Table

Component Package Name Verification Command
Docker Daemon `docker-ce` `docker version`
Docker Compose `docker-compose-plugin` `docker compose version`
Runtime `containerd.io` `systemctl status containerd`

[Image of a Docker Compose YAML file structure for multi-container orchestration]

6. Technical Implementation Details

  • Firewalld Integration: AlmaLinux uses firewalld by default. Docker bypasses firewalld rules by manipulating iptables directly. If your containers cannot communicate externally, ensure Masquerading is enabled: firewall-cmd --zone=public --add-masquerade --permanent.
  • SELinux Constraints: AlmaLinux enforces SELinux in "Enforcing" mode. If you experience permission denied errors when mounting volumes, append the :Z flag to your volume mapping (e.g., -v ./data:/app/data:Z) to allow Docker to relabel the file context.
  • Storage Driver: Docker defaults to overlay2 on AlmaLinux. This is highly compatible with the XFS filesystem used by default in RHEL-based distributions, providing optimal performance on Hovixa NVMe drives.

Sysadmin Advice: After installation, verify the storage driver with **docker info | grep Storage**. If it is not overlay2, your performance will suffer. Additionally, always check your disk space with **df -h** after large builds, as the /var/lib/docker directory can grow rapidly.

هل كانت المقالة مفيدة ؟ 0 أعضاء وجدوا هذه المقالة مفيدة (0 التصويتات)