Why you see this error
If you run docker-compose and get command not found, you likely:
- Don’t have legacy Compose v1 installed, or it was removed.
- Are on a system where Compose v2 is installed as a Docker CLI plugin and should be invoked as
docker compose(space, not hyphen).
Compose v2 is the supported path. It is integrated into the Docker CLI as a plugin and is faster, more reliable, and maintained. The fix is either to use docker compose directly or install the v2 plugin and migrate your scripts.
Quickstart (TL;DR)
macOS and Windows (Docker Desktop):
- Use:
docker compose up -d - Verify:
docker compose version - If not found, update Docker Desktop.
- Use:
Linux (Docker Engine):
- Debian/Ubuntu:
sudo apt-get update && sudo apt-get install -y docker-compose-plugin - Fedora/RHEL/CentOS:
sudo dnf install -y docker-compose-pluginorsudo yum install -y docker-compose-plugin - Arch-based:
sudo pacman -S docker-compose-plugin - Verify:
docker compose version
- Debian/Ubuntu:
Optional shim to keep old scripts working:
- Bash/Zsh: add to your shell profile:
docker-compose() { docker compose "$@"; }
Minimal working example
compose.yaml:
services:
web:
image: nginx:alpine
ports:
- "8080:80"
Run it with Compose v2:
# Start in detached mode
docker compose up -d
# Test locally
curl -I http://localhost:8080/
# Stop and clean up
docker compose down
Step-by-step fix and migration
- Confirm Docker and Compose state
# Docker Engine
docker version
# Compose v2 (preferred)
docker compose version || true
# Legacy v1 (if present)
docker-compose version || true
- If
docker composeprints a version, you’re ready. Use it instead ofdocker-compose. - If neither exists, install the Compose v2 plugin.
- Install Compose v2 as a CLI plugin
- Debian/Ubuntu:
sudo apt-get update
sudo apt-get install -y docker-compose-plugin
- Fedora/RHEL/CentOS:
sudo dnf install -y docker-compose-plugin || sudo yum install -y docker-compose-plugin
- Arch-based:
sudo pacman -S docker-compose-plugin
- Verify after install:
docker compose version
Notes:
- CLI plugins are typically discovered under one of:
- /usr/lib/docker/cli-plugins/
- /usr/libexec/docker/cli-plugins/
- /usr/local/lib/docker/cli-plugins/
- $HOME/.docker/cli-plugins/
- The plugin file is named
docker-composeand must be executable.
- Replace commands in scripts and docs
- Use
docker composeinstead ofdocker-composeeverywhere. - Update CI pipelines to install
docker-compose-pluginon Linux runners.
- Optional: keep
docker-composeworking
- Bash/Zsh shim:
# ~/.bashrc or ~/.zshrc
docker-compose() { docker compose "$@"; }
- PowerShell shim:
# $PROFILE
function docker-compose { docker compose $args }
This avoids touching system paths and cleanly forwards to v2.
- Migrate your Compose files
- Compose v2 supports docker-compose.yml, docker-compose.yaml, and compose.yaml (preferred).
- The
version:field is no longer required; you can remove it in most cases. - Behavior is largely compatible; validate with:
docker compose config
Command mapping (v1 → v2)
| v1 (old) | v2 (new) |
|---|---|
| docker-compose up -d | docker compose up -d |
| docker-compose down | docker compose down |
| docker-compose build | docker compose build |
| docker-compose pull | docker compose pull |
| docker-compose push | docker compose push |
| docker-compose ps | docker compose ps |
| docker-compose logs -f | docker compose logs -f |
| docker-compose exec svc sh | docker compose exec svc sh |
| docker-compose run --rm svc | docker compose run --rm svc |
| docker-compose config | docker compose config |
Platform-specific notes
- macOS: Docker Desktop ships Compose v2; no separate install needed. Use
docker compose. If it’s missing, update Desktop. - Windows: Docker Desktop ships Compose v2. Use
docker composein PowerShell or CMD. Ifdocker-composeis missing, prefer a shim function rather than relying on old shims. - WSL2: If using Docker Desktop’s engine,
docker composeworks inside WSL. If running a native Docker Engine inside the distro, installdocker-compose-pluginin that distro.
Common pitfalls
- Old Python v1 on PATH: If you previously installed
docker-composevia pip, it may mask behavior. Remove it to avoid conflicts:
pip uninstall docker-compose || pip3 uninstall docker-compose
hash -r
Wrong plugin location or permissions: Ensure the plugin is named
docker-compose, is executable, and sits under a recognizedcli-pluginsdirectory.“Cannot connect to the Docker daemon”: This is not a Compose issue. Make sure Docker Engine is running and your user has permission (e.g., is in the
dockergroup on Linux), or prefix withsudo.CI images missing the plugin: Add an install step for
docker-compose-pluginor switch the runner image to one that includes it.
Performance notes with Compose v2
- Faster startup: v2 is Go-based and initializes quicker than Python v1.
- Parallel operations:
docker compose pull --paralleland parallelized builds speed up pipelines. - BuildKit integration: Enable faster, cache-friendly builds with BuildKit (set
DOCKER_BUILDKIT=1fordocker buildand builds triggered from Compose). - Logs and progress: For low-overhead output in CI, use
--progress=plain(for builds) and--ansi never(for logs).
Tiny FAQ
Is
docker-composedeprecated?- Yes. Compose v1 is end-of-life. Use
docker compose(v2).
- Yes. Compose v1 is end-of-life. Use
Can I keep using
docker-composein scripts?- Prefer updating to
docker compose. If that’s hard, add a local shim function that forwards to v2.
- Prefer updating to
How do I check which Compose I’m using?
- Run
docker compose version. If you only seedocker-compose version, you’re on v1.
- Run
Do I need to rewrite my YAML?
- Usually no. Remove the
version:key if present and validate withdocker compose config.
- Usually no. Remove the
Where does the plugin live?
- One of:
/usr/lib/docker/cli-plugins,/usr/libexec/docker/cli-plugins,/usr/local/lib/docker/cli-plugins, or~/.docker/cli-plugins.
- One of: