Posted in

How to Install Docker and Docker Compose on AlmaLinux 9

install docker and compose on almalinux
install docker and compose on almalinux

Docker is an essential tool for modern development, allowing you to package and run applications in isolated containers. almalinux 9, being binary-compatible with RHEL (Red Hat Enterprise Linux), is an excellent choice for a stable, enterprise-grade Docker host.

This guide will walk you through the steps to install Docker Engine and the modern Docker Compose plugin on AlmaLinux 9.

Prerequisites

Before starting, ensure you have:

  • An AlmaLinux 9 system (server or desktop).
  • Root access or a user account with sudo privileges.
  • A stable internet connection.

Step 1: Update Your System

It is best practice to start with a clean and updated system to avoid package conflicts. Open your terminal and run:

sudo dnf update -y

If you have installed Docker previously (or an older version like docker-engine), remove it along with its dependencies to ensure a clean installation:

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

Step 2: Add the Official Docker Repository

AlmaLinux 9 does not include the latest Docker CE (Community Edition) packages in its default repositories. You must add the official Docker repository designed for CentOS/RHEL.

First, install the dnf-plugins-core package, which provides tools to manage repositories:

sudo dnf install -y dnf-plugins-core

Next, add the Docker repository:

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

Step 3: Install Docker Engine and Docker Compose

In modern Docker installations (Docker v2+), Docker Compose is included as a CLI plugin rather than a separate standalone binary. This simplifies management and updates.

Install the Docker Engine, the CLI, the containerd runtime, and the Docker Compose plugin:

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
  • docker-ce: The Docker daemon (engine).
  • docker-ce-cli: The command-line interface to talk to the daemon.
  • containerd.io: The container runtime.
  • docker-compose-plugin: The modern ‘docker compose’ subcommand.

Step 4: Start and Enable Docker

Once installed, the Docker service is not started by default. Start the service and enable it to launch automatically on system boot:

sudo systemctl start docker
sudo systemctl enable docker

Check the status to ensure it is running actively:

sudo systemctl status docker

Step 5: Post-Installation Setup (Manage Docker as Non-Root)

By default, running Docker commands requires sudo. To run Docker commands as your current user without sudo, add your user to the docker group.

  1. Add your current user to the group:sudo usermod -aG docker $USER
  2. Apply the group changes immediately:newgrp docker

You can now run docker ps without using sudo.

Step 6: Verify the Installation

Verify Docker Engine

Run the classic “Hello World” image to confirm that the Docker Engine is working correctly and can pull images from the internet:

docker run hello-world

If successful, you will see a message saying “Hello from Docker!” followed by some informational text.

Verify Docker Compose

Check that the Docker Compose plugin is successfully installed by checking its version:

docker compose version

Note: The command is now docker compose (with a space), not docker-compose (with a hyphen).

Quick Reference Commands

ActionCommand
Start Dockersudo systemctl start docker
Enable on Bootsudo systemctl enable docker
Stop Dockersudo systemctl stop docker
Check Versiondocker --version
Run Composedocker compose up -d

Conclusion

You have successfully installed Docker and Docker Compose on AlmaLinux 9. You can now begin building containerized applications or deploying services using docker-compose.yml files.

Leave a Reply

Your email address will not be published. Required fields are marked *