Docker Compose Install on Ubuntu: The Official Plugin Method

Updated 6 min read By the Self-Hosting HQ Editorial Team
Quick answerOn Ubuntu, install Docker Compose as the docker-compose-plugin package from Docker's official apt repository, together with Docker Engine. After adding Docker's GPG key and repository, run sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin, then check it with docker compose version. Use docker compose (with a space): the standalone docker-compose binary is only supported for backward compatibility, and Compose v1 is no longer maintained.

The right way to do a Docker Compose install on Ubuntu in 2026 is the Compose plugin from Docker’s official apt repository, installed alongside Docker Engine. You then run it as docker compose (with a space). Older guides that download a docker-compose binary with curl describe a legacy method that Docker now keeps only for backward compatibility.

This guide follows Docker’s own documentation as checked in December 2026. At that time Docker’s Ubuntu instructions supported Ubuntu 26.04 LTS, 24.04 LTS, 22.04 LTS and the 26.10 interim release (64-bit only), and the Compose install page referenced Compose v5.6.0 in its manual-install example. Every command below is explained so you know exactly what it changes.

Plugin vs standalone: which one to install

Feature Compose plugin (recommended) Standalone binary (legacy)
Command docker compose up docker-compose up
Install method docker-compose-plugin apt package from Docker’s repo Manual download to /usr/local/bin
Updates With normal apt upgrade Manual re-download
Docker’s position Recommended path on Linux “not recommended and is only supported for backward compatibility purposes”

And don’t confuse either with Compose v1, the original Python tool. Docker’s retired-products page says Compose v1 “is no longer maintained, and users should migrate to Compose v2.” If docker-compose --version reports 1.x on your system, remove it.

Before you start

  • A 64-bit Ubuntu Server or Desktop install of a supported version, fully updated.
  • A user with sudo rights.
  • If this is an existing server, a backup or VM snapshot, because the first step removes conflicting packages.
  • If you use ufw or firewalld, read the firewall note in step 6 before publishing any ports.

Step 1: Remove conflicting packages

Ubuntu’s archive has its own Docker-related packages. Docker’s documentation removes them first so they don’t clash with the official ones:

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)

dpkg --get-selections lists which of those packages are installed, cut -f1 keeps only their names, and apt remove uninstalls them. If none are installed, apt simply reports nothing to remove. Images, containers and volumes stored in /var/lib/docker/ are not deleted by this step.

If you previously installed the standalone binary by hand, delete it too:

sudo rm -f /usr/local/bin/docker-compose

Step 2: Add Docker’s apt repository

These commands are taken from Docker’s Ubuntu installation page. They add Docker’s signing key and a repository definition in the deb822 .sources format:

sudo apt update
sudo apt install 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 <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

What each part does:

  • apt install ca-certificates curl makes sure HTTPS downloads and certificate checks work.
  • install -m 0755 -d /etc/apt/keyrings creates the directory for repository keys.
  • curl … -o /etc/apt/keyrings/docker.asc downloads Docker’s GPG key, and chmod a+r makes it readable so apt can verify packages.
  • The tee block writes /etc/apt/sources.list.d/docker.sources. The Suites line reads your Ubuntu codename from /etc/os-release, and Architectures uses your system’s architecture, so the same block works on any supported release.
  • The final apt update loads the package list from Docker’s repository.

Step 3: Install Docker Engine and the Compose plugin

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

This installs the Docker daemon (docker-ce), the command-line client, the containerd runtime, the Buildx build plugin and the Compose plugin. If you already have Docker Engine from this repository and only need Compose, the Compose install page uses:

sudo apt-get update
sudo apt-get install docker-compose-plugin

Step 4: Verify the installation

sudo docker run hello-world
docker compose version
sudo systemctl status docker

hello-world downloads a tiny test image and prints a confirmation message if the engine works. docker compose version prints the installed Compose version. systemctl status docker shows whether the service is running; Docker’s docs say to start it with sudo systemctl start docker if it isn’t. On Ubuntu the service normally starts at boot automatically; if not, Docker’s post-install page enables it with sudo systemctl enable docker.service and sudo systemctl enable containerd.service.

Step 5 (optional): Run Docker without sudo

Docker’s post-installation guide adds your user to the docker group:

sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker

groupadd creates the group (it may already exist), usermod -aG appends your user to it, and newgrp applies the change to the current shell; logging out and back in also works.

The docker group is root accessDocker's documentation warns that the docker group "grants root-level privileges to the user." Only add trusted accounts, and never expose the Docker socket (/var/run/docker.sock) or the Docker API to the network or to untrusted containers.

Step 6: Your first compose.yaml

Docker says the default Compose file name is compose.yaml (preferred) or compose.yml, with docker-compose.yaml still accepted for backward compatibility. Create a project folder and a minimal file:

mkdir -p ~/stacks/hello && cd ~/stacks/hello
nano compose.yaml
services:
  web:
    image: nginx:stable
    ports:
      - "127.0.0.1:8080:80"
    restart: unless-stopped

This defines one service named web using the official Nginx image. The port mapping binds container port 80 to port 8080 on 127.0.0.1 only, so it isn’t reachable from other machines. restart: unless-stopped brings it back after a reboot unless you stopped it yourself. Note there is no version: line; current Compose doesn’t need one.

Then manage it with the core commands:

docker compose up -d
docker compose ps
docker compose logs -f
docker compose down

up -d creates and starts the containers in the background, ps lists them, logs -f follows their output (Ctrl+C to exit), and down stops and removes the containers and network while keeping named volumes.

Firewall note: Docker’s Ubuntu page warns that if you use ufw or firewalld, ports you publish with Docker bypass your firewall rules. Binding to 127.0.0.1 (as above) or to a specific LAN IP is the safest habit. Publish on all interfaces only when you mean to, and never forward container admin ports from your router; use a VPN or a reverse proxy with TLS and authentication instead.

Troubleshooting common errors

Symptom Likely cause Fix
docker-compose: command not found Using the legacy hyphenated command Use docker compose (space)
docker: 'compose' is not a docker command Plugin not installed sudo apt install docker-compose-plugin
permission denied … docker.sock User not in docker group, or group not applied Use sudo, or do step 5 and log out/in
Conflicts: docker.io during install Ubuntu’s packages still installed Repeat step 1
docker-compose --version shows 1.x Old Python Compose v1 Remove it; use the plugin

Organizing stacks so backups are easy

Compose works best when each application lives in its own folder. A simple, predictable layout saves a lot of time when you need to restore or move a service to another machine:

mkdir -p ~/stacks/notes/data

Inside ~/stacks/notes you keep compose.yaml and, if the app needs secrets, a .env file that Compose reads automatically for variable substitution. Point the container’s data at ./data with a bind mount, so the whole application, configuration plus data, sits in one directory tree.

That layout gives you three practical benefits:

  • Backups are a folder copy. Stop the stack with docker compose down, copy or snapshot the folder to another disk, then start it again with docker compose up -d. Stopping first avoids copying a database mid-write.
  • Moving hosts is simple. Copy the folder to the new server, install Docker the same way, and run docker compose up -d.
  • Changes are reviewable. Many people keep their compose files (without the .env secrets) in a private Git repository, so every change has a history.

Remember that docker compose down keeps named volumes by default; Docker’s reference says they are only removed when you pass -v or --volumes. Be careful with that flag, because it deletes data stored in named volumes.

Rootless mode and other hardening options

By default the Docker daemon runs as root. Docker’s security documentation notes that it “requires root privileges unless you opt-in to Rootless mode,” and that only trusted users should control the daemon. For a home server, the most effective hardening steps are simple:

  • Don’t mount /var/run/docker.sock into containers unless you fully trust that image and understand why it needs it; access to the socket is equivalent to root on the host.
  • Never enable the Docker API on a TCP port reachable from your network. Docker’s docs say that exposing it over HTTP without TLS is not permitted, and even with TLS it should only be reachable from a trusted network or VPN.
  • Prefer official or well-maintained images, pin a major version tag rather than latest for anything important, and read release notes before upgrading.
  • Keep admin web interfaces of your containers on your LAN or VPN only.

Rootless mode is worth exploring later, but it changes networking and storage behavior, so get comfortable with the standard install first.

Keeping Docker and Compose updated

Because both come from Docker’s repository, normal system updates keep them current:

sudo apt update && sudo apt full-upgrade

Before upgrading a production host, back up your compose files and data folders, or snapshot the VM if it runs on a hypervisor. To update the containers themselves, run docker compose pull followed by docker compose up -d inside each project folder.

Next steps

With Docker and Compose working, you can deploy self-hosted apps one folder at a time. If you’re still planning the server, read how to set up a home server; if you want this Docker host as a VM, follow the Proxmox setup guide. For safe remote access, see Tailscale vs WireGuard. More container guides are in the Docker section.

Frequently asked questions

Should I install docker.io or docker-ce on Ubuntu?

Docker's documentation installs docker-ce from Docker's own repository and lists docker.io, docker-compose and docker-compose-v2 among the conflicting packages to remove first. Mixing the two sources causes version conflicts.

Why does docker-compose say command not found?

The plugin is invoked as docker compose, with a space. The hyphenated docker-compose only exists if you installed the legacy standalone binary, which Docker supports only for backward compatibility.

Do I still need the version line at the top of compose.yaml?

Current Compose releases don't need it; Docker's Compose file reference treats the top-level version element as obsolete. You can remove it from older files.

Can I install Docker on Ubuntu inside a Proxmox LXC container?

It can work, but it needs container nesting and has more edge cases. A small Ubuntu VM is the simpler, more isolated choice for a Docker host.

Sources

  1. Install Docker Engine on Ubuntu: Docker Docs
  2. Install the Docker Compose plugin: Docker Docs
  3. Install the Docker Compose standalone: Docker Docs
  4. Linux post-installation steps for Docker Engine: Docker Docs
  5. Deprecated and retired Docker products and features: Docker Docs
  6. How Compose works: Docker Docs
  7. Docker Engine security: Docker Docs
  8. Version and name top-level elements: Docker Docs
  9. docker compose down: Docker Docs
Written and maintained by the Self-Hosting HQ Editorial Team

We research every guide from manufacturer documentation, government and standards bodies, and other primary sources, which are cited at the end of each article. We do not accept payment for coverage. Read our editorial policy to see how articles are researched, fact-checked and updated, or tell us if something is out of date.