Docker Compose is the standard tool for defining and running multi-container applications. Instead of managing each container individually with long docker run commands, you describe your entire application stack in a single docker-compose.yml file and bring everything up with one command: docker compose up.
This guide covers three installation methods for Docker Compose on Ubuntu 26.04 LTS (codename Resolute), released April 2026. By the end you will have Docker Engine 29.4.0 and Docker Compose v5.1.2 running, Docker configured without sudo, and a working multi-container example to confirm the setup.
💡 Quick Reference
26.04 LTS (Resolute)
6.14 / 7.0
29.4.0
v5.1.2
v2 (exclusive on Ubuntu 26.04)
Docker official repository
Prerequisites
Before starting, ensure you have:
- A running Ubuntu 26.04 LTS system (server or desktop)
- A user account with
sudoprivileges - Internet connectivity to reach Docker’s package repositories and GitHub
- At least 2 GB of free disk space
If this is a fresh server, update the system first:
sudo apt update && sudo apt upgrade -y
Method 1: Install from Docker’s Official Repository (Recommended)
This method gives you the latest Docker Engine and Compose versions directly from Docker Inc., with the fastest security update cadence. Docker Compose v2 is bundled as a plugin (docker-compose-plugin) and invoked as docker compose (without a hyphen).
Step 1 — Remove Old Docker Packages
Remove any conflicting Docker packages that may have been installed from the Ubuntu repository:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 \
podman-docker containerd runc; do
sudo apt remove -y $pkg 2>/dev/null
done
Step 2 — Install Dependencies and Add Docker GPG Key
# Install required packages
sudo apt update
sudo apt install -y ca-certificates curl
# Create the keyrings directory
sudo install -m 0755 -d /etc/apt/keyrings
# Download Docker's official GPG key
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
Step 3 — Add the Docker Repository
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \ https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update
Step 4 — Install Docker Engine and Docker Compose Plugin
sudo apt install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
This single command installs:
docker-ce— Docker Engine (Community Edition)docker-ce-cli— thedockercommand-line interfacecontainerd.io— the container runtimedocker-buildx-plugin— extended build capabilities (multi-platform builds)docker-compose-plugin— Docker Compose v2, used asdocker compose
Method 2: Install from Ubuntu Repository (Simpler, Slightly Older Version)
If you prefer to use Ubuntu’s own tested packages and do not need the very latest version, the Ubuntu repository provides a stable build with integrated security updates:
sudo apt update sudo apt install -y docker-compose-v2
This automatically installs docker.io (Docker Engine from the Ubuntu repository) as a dependency. The docker-compose-v2 package provides the docker compose command. This is the simplest one-command install, though the Docker version may lag behind the official Docker repository by a few minor releases.
Method 3: Manual Binary Installation (Specific Version Control)
For air-gapped environments, specific version pinning, or per-user installation without system-wide changes, download the Docker Compose binary directly from GitHub:
# Set Docker config directory
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
# Download Docker Compose v5.1.2 binary
curl -SL https://github.com/docker/compose/releases/download/v5.1.2/docker-compose-linux-x86_64 \
-o $DOCKER_CONFIG/cli-plugins/docker-compose
# Make it executable
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
For ARM64 systems (Raspberry Pi, AWS Graviton, Apple Silicon VMs):
curl -SL https://github.com/docker/compose/releases/download/v5.1.2/docker-compose-linux-aarch64 \
-o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
Note: Manual installs do not auto-update. You must repeat this process to upgrade to a newer version. For most users, Method 1 (Docker official repository) is preferred.
Verify the Installation
After completing any of the three methods above, verify both Docker Engine and Docker Compose are working correctly:
# Check Docker Engine version docker --version # Check Docker Compose version docker compose version # Run the hello-world container to verify Docker is functional sudo docker run hello-world
Expected output:
Docker version 29.4.0, build abcdef1 Docker Compose version v5.1.2 Hello from Docker! This message shows that your installation appears to be working correctly.
Run Docker Without sudo (Recommended)
By default, the Docker daemon runs as root and requires sudo for every command. Adding your user to the docker group allows running Docker commands without sudo:
# Add your user to the docker group sudo usermod -aG docker $USER # Apply the new group membership without logging out newgrp docker # Verify it works without sudo docker run hello-world
docker group have effective root privileges on the host system through Docker’s container runtime. Only add trusted users to this group. On production servers, consider using rootless Docker instead.Enable Docker to Start on Boot
Docker Engine is enabled on boot by default when installed from the Docker official repository. Verify and enable it manually if needed:
# Enable Docker and containerd to start on boot sudo systemctl enable docker.service sudo systemctl enable containerd.service # Check current status sudo systemctl status docker
Your First docker-compose.yml File
Create a working directory and a docker-compose.yml file to test your installation with a real multi-container application. This example runs WordPress with MariaDB and Redis — three containers defined in one file:
mkdir -p ~/docker-test && cd ~/docker-test nano docker-compose.yml
Paste the following content:
services:
db:
image: mariadb:11
restart: always
environment:
MARIADB_ROOT_PASSWORD: rootpass
MARIADB_DATABASE: wordpress
MARIADB_USER: wpuser
MARIADB_PASSWORD: wppass
volumes:
- db_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
restart: always
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
retries: 3
wordpress:
image: wordpress:6-apache
restart: always
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_PASSWORD: wppass
WORDPRESS_DB_NAME: wordpress
volumes:
- wp_data:/var/www/html
volumes:
db_data:
wp_data:
Start the stack:
# Start all containers in the background (-d = detached mode) docker compose up -d # Watch the logs to see all three containers start docker compose logs -f
Once all containers are healthy, open http://localhost:8080 in your browser to see the WordPress setup page. To stop the stack:
docker compose down
Essential Docker Compose Commands
Using Environment Variables with .env Files
Store sensitive values like database passwords outside your docker-compose.yml in a .env file in the same directory:
# .env file MARIADB_ROOT_PASSWORD=your-strong-root-password MARIADB_DATABASE=appdb MARIADB_USER=appuser MARIADB_PASSWORD=your-strong-app-password APP_PORT=8080
Reference these variables in docker-compose.yml:
services:
db:
image: mariadb:11
environment:
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD}
MARIADB_DATABASE: ${MARIADB_DATABASE}
MARIADB_USER: ${MARIADB_USER}
MARIADB_PASSWORD: ${MARIADB_PASSWORD}
ports:
- "${APP_PORT}:80"
Add .env to .gitignore to prevent committing secrets to version control:
echo ".env" >> .gitignore
Troubleshooting on Ubuntu 26.04
Issue 1: “Cannot connect to the Docker daemon” Error
If you see Cannot connect to the Docker daemon at unix:///var/run/docker.sock, the Docker service is not running. Start it:
sudo systemctl start docker sudo systemctl status docker
Issue 2: Permission Denied Without sudo
If you added yourself to the docker group but still see permission errors, either the group membership has not taken effect yet or newgrp docker was not run. Log out and log back in, or run:
newgrp docker # Verify group membership groups $USER
Issue 3: Old Images Not Compatible with cgroup v2
Ubuntu 26.04 uses cgroup v2 exclusively (no cgroup v1 fallback). Very old container images — Alpine 3.13 and earlier, legacy CentOS 7 images, and some older MySQL images — may fail to start. Update to current image versions. For MySQL, use mysql:8.4 or mariadb:11 which have full cgroup v2 support.
Issue 4: docker-compose Command Not Found
Docker Compose v2 uses docker compose (space, not hyphen). The old docker-compose (with hyphen) command was deprecated in v2. If scripts rely on the hyphenated form, create an alias:
# Add to ~/.bashrc for persistent alias echo 'alias docker-compose="docker compose"' >> ~/.bashrc source ~/.bashrc
Issue 5: Port Already in Use
If docker compose up fails with “port is already allocated” or “address already in use,” another service is using that port. Find it:
# Find what is using port 8080 sudo ss -tlnp | grep 8080 # Or use lsof sudo lsof -i :8080
Either stop the conflicting service or change the host port in your docker-compose.yml (e.g. change "8080:80" to "8081:80").
Issue 6: Verify Docker Repository Is Correctly Configured
If apt update throws errors about the Docker repository, verify the repository configuration and GPG key are correct:
# Check the repository file cat /etc/apt/sources.list.d/docker.list # Should output something like: # deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] # https://download.docker.com/linux/ubuntu resolute stable # Verify the GPG key exists ls -la /etc/apt/keyrings/docker.asc
Upgrading Docker Compose
If you installed via Method 1 (Docker official repository), upgrade Docker Compose along with all Docker packages through the normal APT update process:
sudo apt update
sudo apt upgrade docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
For Method 3 (manual binary), download the new binary and replace the existing one:
# Check latest version at:
# https://github.com/docker/compose/releases
NEW_VERSION="v5.1.2" # Replace with latest version
curl -SL "https://github.com/docker/compose/releases/download/${NEW_VERSION}/docker-compose-linux-x86_64" \
-o $HOME/.docker/cli-plugins/docker-compose
chmod +x $HOME/.docker/cli-plugins/docker-compose
docker compose version
Frequently Asked Questions
What is the difference between docker compose and docker-compose?
Docker Compose v1 was a standalone Python binary installed as docker-compose (with a hyphen). Docker Compose v2 — which is what you install on Ubuntu 26.04 — is a Go-based CLI plugin integrated directly into the Docker CLI, invoked as docker compose (with a space). Version 2 is significantly faster, supports all current Compose file features, and is the only version receiving active development. The docker-compose v1 binary is end-of-life since June 2023.
Can I install a specific version of Docker Compose?
Yes. For Method 3 (manual binary), specify the exact version in the GitHub download URL. For Method 1 (Docker repository), list available versions and pin a specific one:
apt-cache madison docker-compose-plugin # Install a specific version sudo apt install docker-compose-plugin=5.1.2-1~ubuntu.26.04~resolute
How do I uninstall Docker Compose?
For Method 1 (Docker repository):
sudo apt remove docker-compose-plugin
For Method 3 (manual binary):
rm $HOME/.docker/cli-plugins/docker-compose
Does Docker Compose work on Ubuntu 26.04 arm64?
Yes. Docker CE and Docker Compose v2 have full arm64 support. If using Method 1, the repository automatically selects the correct architecture via $(dpkg --print-architecture) in the sources entry. For Method 3, use the docker-compose-linux-aarch64 binary instead of docker-compose-linux-x86_64.
Linux Server & DevOps Services · Saudi Arabia
Need expert Linux and Docker infrastructure support?
Visit To Me provides Linux server administration, Docker and container infrastructure setup, DevOps pipeline implementation, and managed server support for businesses in Saudi Arabia and globally. Whether you need a fresh Docker environment configured, an existing server secured and optimised, or an ongoing managed Linux infrastructure — we deliver with a written SLA and 24-hour response.
📍 Riyadh · 🌍 Remote worldwide · ⏰ 24h response · 📋 Written SLA on every engagement
Leave a Reply