How to Install Docker Compose on Ubuntu 24.04

Install Docker Compose on Ubuntu 24.04 with Docker’s official APT repository, run a two-service stack, verify it, and fix common errors fast.
A polished 3D illustration of container blocks and a server rack with cyan light trails and an orange Ubuntu-inspired accent.

Install Docker Compose on Ubuntu 24.04 by configuring Docker’s signed repository, installing Compose v2, and running a small web-and-cache stack. You will have a repeatable compose.yaml project to inspect and manage in about ten minutes, without publishing its test services to the internet.

Prerequisites

  • A 64-bit Ubuntu 24.04 LTS (Noble Numbat) VPS with at least 2 GB of RAM and 10 GB of free disk space.
  • SSH access as root, or a normal user with working sudo privileges.
  • Outbound HTTPS access to download.docker.com and Docker Hub so APT and Compose can retrieve packages and images.
  • A VPSLake Linux VPS if you need a clean Ubuntu server with root access.
  • No domain is needed for this private test. A domain becomes useful when you later put a public service behind a TLS reverse proxy.

The commands assume a sudo-enabled SSH user. If you are logged in as root, remove sudo from the commands. The Docker group gives members root-equivalent control over the host, so use it only for accounts you trust.

Step 1: Confirm Ubuntu 24.04 and update APT

Docker publishes packages for named Ubuntu releases, so verify that this server reports noble before adding a source for it.

grep -E '^(PRETTY_NAME|VERSION_CODENAME)=' /etc/os-release
dpkg --print-architecture
sudo apt update

The release should be Ubuntu 24.04 LTS with an architecture such as amd64 or arm64:

PRETTY_NAME="Ubuntu 24.04.3 LTS"
VERSION_CODENAME=noble
amd64

If apt update reports a repository, DNS, or signature error, fix that first. A stale or partially updated package index can make a correct Docker repository appear empty.

Step 2: Add Docker’s signed Noble repository

The keyring and deb822 source file let APT verify Docker packages while keeping this installation tied to Ubuntu 24.04’s noble suite.

sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
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
sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null <<'EOF'
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: noble
Components: stable
Architectures: amd64 arm64 armhf ppc64el s390x
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update

The architecture list matches Docker’s supported Ubuntu packages; APT will select the architecture reported by the machine. Confirm that the repository offers an Engine candidate before installing it:

apt-cache policy docker-ce

A successful check shows a Candidate version and a package source containing download.docker.com and noble. Docker’s Ubuntu installation documentation is the authoritative reference for future repository changes.

Step 3: Install Docker Engine and Compose v2

Compose v2 is a Docker CLI plugin, so installing docker-compose-plugin gives you the maintained docker compose command rather than the obsolete hyphenated executable.

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo systemctl is-active docker
sudo docker version --format 'Client {{.Client.Version}} / Server {{.Server.Version}}'
sudo docker compose version

The service check should return active, followed by Docker client/server versions and a Compose v2 version. Exact patch numbers change as Docker publishes updates:

active
Client 29.x.y / Server 29.x.y
Docker Compose version v2.x.y

Run the vendor’s small smoke test before creating a project. It downloads hello-world, starts it, prints a confirmation, and exits.

sudo docker run --rm hello-world

Look for this confirmation in the output:

Hello from Docker!
Your installation appears to be working correctly.

Step 4: Enable Compose for your SSH user

Docker’s Unix socket is root-owned by default; adding your account to the docker group avoids sudo on every Compose command, but it also grants administrative control of Docker.

sudo groupadd --force docker
sudo usermod -aG docker "$USER"

Start a new SSH session so the group change is loaded, then check both membership and daemon access:

id -nG
docker info --format 'Server {{.ServerVersion}}'

The group list should contain docker, and the second command should print a server version. Until reconnecting, use sudo docker compose ... or run newgrp docker for the current shell. For a stronger privilege boundary, investigate Docker rootless mode instead of using the group.

Step 5: Create a two-service Compose project

This project runs Nginx and Redis together so you can see service status, a private Compose network, a health check, and persistent storage in one small example. Nginx is bound to loopback, while Redis has no published port at all.

Create a page and move into a dedicated directory:

mkdir -p ~/compose-noble/site
cd ~/compose-noble
printf '%s\n' 'Docker Compose on Ubuntu 24.04 is running.' > site/index.html

Create a local environment file for the Redis password. Replace the placeholder with a long, unique value; it is intentionally not a usable credential.

tee .env >/dev/null <<'EOF'
REDIS_PASSWORD=YOUR_STRONG_REDIS_PASSWORD
EOF
chmod 600 .env

Now create compose.yaml:

services:
  web:
    image: nginx:alpine
    ports:
      - "127.0.0.1:8088:80"
    volumes:
      - ./site:/usr/share/nginx/html:ro
    depends_on:
      cache:
        condition: service_healthy

  cache:
    image: redis:7-alpine
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD:?Set REDIS_PASSWORD in .env}
    command: ["sh", "-c", "exec redis-server --requirepass \"$$REDIS_PASSWORD\""]
    volumes:
      - redis_data:/data
    healthcheck:
      test: ["CMD-SHELL", "redis-cli -a \"$$REDIS_PASSWORD\" ping | grep PONG"]
      interval: 5s
      timeout: 3s
      retries: 12

volumes:
  redis_data:

The read-only site mount stops Nginx from changing your files. The named volume survives container replacement, and the Redis service remains on Compose’s private network because it has no ports entry. $$REDIS_PASSWORD makes Compose pass the variable to the container instead of expanding it on the host while it renders the file.

Docker’s Compose file reference documents the service, volume, health check, and dependency keys used here.

Step 6: Validate and start the stack

Render the configuration first so YAML indentation, variable substitution, and the required password are checked before images are pulled.

docker compose config --quiet
docker compose pull
docker compose up -d
docker compose ps

The first command should produce no output and return status 0. After the images download, both services should be running and Redis should be healthy; the generated project name may differ if you choose another directory:

NAME                  SERVICE   STATUS                   PORTS
compose-noble-web-1   web       Up                       127.0.0.1:8088->80/tcp
compose-noble-cache-1 cache     Up (healthy)

Verify Docker Compose on Ubuntu 24.04

Check the served page, query Redis from inside its container, and inspect recent logs. These checks prove that the Compose plugin can render the file, start both services, and pass the protected Redis setting.

curl --fail --silent --show-error http://127.0.0.1:8088
docker compose exec cache sh -c 'redis-cli -a "$REDIS_PASSWORD" ping'
docker compose logs --tail 20 web cache

The page and Redis check should return:

Docker Compose on Ubuntu 24.04 is running.
PONG

Because Nginx listens only on 127.0.0.1, a browser on your workstation cannot reach it directly. For private testing, create an SSH tunnel from your workstation with ssh -L 8088:127.0.0.1:8088 USER@SERVER_IP, then open http://127.0.0.1:8088 locally.

Do not publish Redis or casually expose Docker ports. Docker documents that published container ports can bypass ordinary UFW filtering; when you later expose an application, allow only the required ports and apply a deliberate Docker-aware policy. VPSLake’s UFW firewall generator can help draft the host rules.

Troubleshooting

docker: 'compose' is not a docker command

The plugin is missing, or the shell is calling a different Docker installation. Refresh the Noble package index and install the plugin from Docker’s repository:

sudo apt update
sudo apt install -y docker-compose-plugin
docker compose version

Use a space in docker compose. The docker-compose command belongs to the legacy standalone tool and is not needed for this setup.

permission denied while trying to connect to the Docker daemon socket

Your current session has not loaded the new group membership, or the account was added to a different user than the one running the command. Open a new SSH session, run id -nG, and retry. sudo docker compose ... is a temporary workaround, but remember that membership in docker is effectively root access.

E: Package 'docker-ce' has no installation candidate

APT is not reading the Noble source, often because the source file has the wrong suite or apt update failed. Inspect the file and refresh the cache:

cat /etc/apt/sources.list.d/docker.sources
sudo apt update
apt-cache policy docker-ce

The file must contain Suites: noble, and the update must finish without errors. If the VPS already has Ubuntu’s docker.io packages or a legacy Compose installation, inventory existing containers first; do not remove a working production Docker installation without a migration plan.

dependency failed to start or Redis is unhealthy

Compose could not authenticate to Redis during its health check. Check the rendered configuration and logs, then make sure .env contains REDIS_PASSWORD with no spaces around the equals sign:

docker compose config
docker compose logs cache

The named volume can retain data and configuration from an earlier initialization. For a disposable test only, docker compose down -v removes redis_data before you start again; never use -v when the volume contains data you need.

Hardening

  • Keep .env at mode 600, exclude it from source control, and use a managed secret store for production credentials.
  • Leave application ports on loopback until authentication, TLS, and a reviewed firewall policy are ready. Never publish Redis directly to the public internet.
  • Configure Docker log rotation or a centralized logging driver so long-running containers do not consume the VPS disk.
  • Pin production images to reviewed tags or immutable digests, then update them deliberately with docker compose pull and docker compose up -d.

FAQ

Is Docker Compose installed with Docker Engine on Ubuntu 24.04?

Not necessarily. The official Docker repository provides the separate docker-compose-plugin package, which adds the docker compose subcommand. Always verify it with docker compose version after installation.

Why does this guide use compose.yaml instead of docker-compose.yml?

Compose v2 supports both filenames, but compose.yaml is the current, concise default for a new project. If you inherit another filename, pass it explicitly with docker compose -f FILE up -d rather than renaming a shared deployment file.

Will docker compose down delete the Redis data?

A normal down removes the containers and network but keeps the named redis_data volume. The -v option also deletes that volume, so reserve it for a disposable reset after confirming that no data must be retained.

How can I open the sample page from my own computer?

Keep the service private and use an SSH tunnel such as ssh -L 8088:127.0.0.1:8088 USER@SERVER_IP. For a public deployment, put the application behind a TLS reverse proxy, allow only ports 80 and 443 in the firewall, and keep Redis on the internal Compose network.

Samrat Ghosh
Written by

Samrat Ghosh

Founder & Infrastructure Engineer

Samrat Ghosh is the founder of VPSLake, where he builds and runs the remote desktop and VPS hosting infrastructure the company is built on. He writes hands-on guides about RDP, Windows Server, VPS management and secure remote access - the practical documentation he wishes had…

Previous Article

How to Install Docker Compose on Ubuntu 22.04

Write a Comment

Leave a Comment

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

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨