Install Docker Compose on Ubuntu 24.04: Full Guide

Running containers on a server is one of the most practical skills a self-hosting enthusiast can learn, and Docker is still the standard way to do it. To install docker compose ubuntu 24.04 systems the right way, you should use Docker’s official apt repository instead of the older docker.io package that ships with Ubuntu. The distro package trails upstream releases, which means slower security patches and no guarantee the Compose tooling will match your Engine version. This guide walks through the full process: adding the official repository, installing Docker Engine plus the Docker Compose plugin, verifying everything with the hello-world image, configuring non-root access, and testing a real compose file on Ubuntu 24.04 (Noble Numbat), the current LTS release.

Why the Official Repository Beats docker.io

Ubuntu 24.04 includes a docker.io package that works for quick experiments, but it is a snapshot that ages fast. Security fixes and new Compose plugin features arrive upstream first, and mixing an old Engine with a newer Compose binary is a classic source of confusing errors. Installing from Docker’s own apt repository keeps the Engine, the CLI, containerd, and the Docker Compose plugin on the same release line, and a normal apt upgrade updates them together.

If you installed Docker from Ubuntu’s repos before, remove those packages first so the two sources do not fight each other:

sudo apt remove -y docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc

Removing them does not delete your volumes or compose files, so this is safe to run on a dev box you want to switch over.

Prerequisites

  • An Ubuntu 24.04 server or VM (1 GB of RAM is enough for this guide; any VPS will do)
  • A user account with sudo privileges
  • Outbound HTTPS access so apt can reach Docker’s download server

No previous Docker experience is required; every command below runs in the order shown.

Step 1: Add the Docker Apt Repository

The docker apt repository is where all official Docker packages for Ubuntu live. Start by installing the tools needed to fetch and verify Docker’s GPG key:

sudo apt update
sudo apt install -y ca-certificates curl

Next, create a keyring directory and download Docker’s signing key into it:

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

Now register the repository. Note the VERSION_CODENAME fallback: some minimal cloud images do not set UBUNTU_CODENAME, so the command below uses whichever value exists:

echo 
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu 
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | 
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

On Ubuntu 24.04 the codename should read noble. If apt update reports a 404 from download.docker.com, check the generated file with cat /etc/apt/sources.list.d/docker.list — a wrong codename is the usual culprit.

Step 2: Install Docker Engine and the Docker Compose Plugin

With the repository in place, install the Engine and its companions in one command:

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

Here is what each package does:

  • docker-ce — the Docker Engine daemon itself
  • docker-ce-cli — the docker command-line client
  • containerd.io — the container runtime the Engine builds on
  • docker-buildx-plugin — the modern image builder (needed for multi-arch builds)
  • docker-compose-plugin — the Docker Compose plugin that adds the docker compose subcommand

Modern Compose is a plugin, not a separate binary. That means you run docker compose (with a space), and the old standalone docker-compose command is no longer maintained. Confirm both versions installed cleanly:

sudo docker --version
sudo docker compose version

Both commands should print version numbers with no errors.

Step 3: Verify the Install with hello-world

The classic smoke test pulls a tiny image and runs it:

sudo docker run hello-world

When the docker engine ubuntu service is healthy, you will see a friendly message explaining that the daemon pulled the image, created a container, and executed it. That output proves three things at once: the daemon is running, image pulls work through your network, and container execution is fine.

Also check that the daemon starts on boot, which the package installer normally enables automatically:

sudo systemctl is-enabled docker
sudo systemctl status docker --no-pager

If the service is inactive, start and enable it with sudo systemctl enable --now docker.

Post-Install: Run Docker Without sudo

Typing sudo before every Docker command gets old fast. Add your user to the docker group so the daemon socket is accessible directly:

sudo usermod -aG docker $USER
newgrp docker

newgrp applies the change in the current shell; or log out and back in. Test it without sudo:

docker run hello-world

One honest warning: the docker group is effectively root-equivalent, because a container can mount the host filesystem. Only add users you fully trust to this group, and never do it for a shared or untrusted account.

Step 4: Test a Real Compose File

Now put the Compose plugin to work with a small but real stack. Create a directory and a compose.yaml:

mkdir -p ~/compose-test && cd ~/compose-test
cat > compose.yaml <<'EOF'
services:
  web:
    image: nginx:alpine
    ports:
      - "8080:80"
    restart: unless-stopped
EOF

Start the stack in the background, list it, and check it answers:

docker compose up -d
docker compose ps
curl -I http://localhost:8080

You should see an HTTP/1.1 200 OK response from Nginx. When you are done experimenting, tear the stack down (the -v flag also removes the anonymous volume):

docker compose down -v

That is the complete loop: define services in YAML, bring them up, inspect them, and remove them cleanly.

For the slower tour, your first docker compose file, explained walks through every field. The same loop then scales to real stacks: self-host Nextcloud with Docker Compose for file sync, self-host n8n on a VPS for automation, install Uptime Kuma with Docker to monitor the box itself, and install Ghost CMS with Docker and MySQL for a blog all start from a file like this one.

Everyday Compose Commands Worth Memorizing

Installation is the easy part; operating stacks is the ongoing work. Four commands cover most days:

docker compose logs -f web     # follow one service's logs
docker compose exec web sh     # shell inside a running container
docker compose pull            # fetch newer images, then re-run up -d
docker compose config          # render and validate the compose file

Run docker compose config after every edit, before up -d: it catches broken indentation and unresolved variables before anything runs. Named volumes survive docker compose down and are deleted only with -v — the difference between a restart and a deleted database.

Optional: Tune the Docker Daemon

One setting worth changing on any server is log rotation. Without it, a chatty container can fill your disk with JSON logs. Create /etc/docker/daemon.json:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Then restart the daemon to apply it:

sudo systemctl restart docker

This caps each container's logs at three 10 MB files. Old containers keep running; only new ones pick up the limits, so recreate stacks if you want the policy to apply immediately.

Troubleshooting: install docker compose ubuntu 24.04 Errors

Most failures on a fresh install come from a short list. Work through these before reinstalling anything.

"docker: command not found" after installing

The package went to /usr/bin/docker. If your shell cannot find it, either the install step was skipped or you are in a different environment (for example, inside a container or chroot). Re-run the install command and confirm ls /usr/bin/docker exists.

"permission denied" after adding yourself to the docker group

Group membership only takes effect in new login sessions. Run newgrp docker or log out and back in, then try again.

"Cannot connect to the Docker daemon" at the socket

The CLI is installed but the daemon is not running. Check sudo systemctl status docker --no-pager and start it with sudo systemctl enable --now docker. If it still fails and you edited /etc/docker/daemon.json, validate that JSON first: a syntax error stops the daemon cold.

"docker: 'compose' is not a docker command"

The Docker Compose plugin is missing. Install it explicitly with sudo apt install -y docker-compose-plugin and verify with docker compose version.

apt update returns 404 from download.docker.com

Your repo file has the wrong codename. It must say noble for Ubuntu 24.04. Regenerate it with the command from Step 1.

GPG error: NO_PUBKEY

The key file and the signed-by path disagree. Re-run the keyring download from Step 1 exactly as written, then sudo apt update again.

FAQ

Do I need to reboot after installing Docker?

No. The installer starts the daemon immediately, and the group change takes effect with newgrp or a fresh login.

Can I just use the docker.io package from Ubuntu's repos?

You can, but you give up version parity between the Engine and the Compose plugin, and updates arrive late. For a server you plan to keep, the official repository is the better default.

How do I update Docker later?

The same way you update anything else: sudo apt update && sudo apt upgrade. The Engine and Compose plugin upgrade together because they come from one repository.

Conclusion

You now have a clean Docker setup on Ubuntu 24.04: the official repository configured, the Engine and Compose plugin installed from the same release line, hello-world verified, non-root access working, and a tested compose workflow. From here, the same pattern — a compose.yaml plus docker compose up -d — covers most self-hosting projects, from reverse proxies to databases. Keep the daemon's logs rotated, update with apt like everything else, and your container host will stay boring in the best possible way.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.