Why docker-compose: command not found Happens (and the Fix)
You followed a tutorial, typed docker-compose up, and your terminal answered with docker-compose: command not found. Before you start reinstalling Docker from scratch, here's the short version: your setup almost certainly isn't broken. You're running into a naming change that Docker made a few years ago, and the tutorial you're following just hasn't caught up. This guide walks you through a thirty-second check to confirm exactly what's going on, then gives you the one fix that matches your situation, instead of a long list of things to try in order.
I've walked more than a few clients through this exact message, usually while they're staring at a README written back in 2021. Once you see what's actually happening, it takes about two minutes to sort out.
Diagnose Your Setup in 30 Seconds
Before you touch anything, you need a terminal open on the machine giving you trouble (your Ubuntu server, your WSL window, your Raspberry Pi, wherever the error showed up). You don't need special permissions for this first part; you're just asking two questions.
Run these two commands, one after the other:
docker compose version
docker-compose version
Notice the difference: the first has a space between "docker" and "compose", the second has a hyphen. That space or hyphen is the entire story here. Think of it like your phone's contacts app: you search for a name and get nothing, not because the contact vanished, but because they changed their display name and you're still typing the old one.
Read what each command gives you back, then match it to the row below.
| docker compose version | docker-compose version | What it means |
|---|---|---|
| Prints a version number | Command not found | Go to Fix A |
| Command not found | Prints a version number | Go to Fix B |
| "docker: 'compose' is not a docker command" | Command not found | Go to Fix C |
| "docker: command not found" (both fail) | Command not found | Go to Fix D |
If you saw the third row, that's worth pausing on. The message "docker: 'compose' is not a docker command" is Docker's Engine telling you it has no idea what "compose" means as a subcommand, which is a slightly different problem from a plain "docker unknown command docker compose" typo. It usually means your Docker install is old enough that it predates the Compose plugin, or the plugin never got installed alongside it. Fix C covers that too.
Why the Hyphen Matters: docker compose vs docker-compose
Here's what actually happened, and why it matters more now than it used to.
Docker Compose started life in 2014 as a separate Python program you installed on its own, called with a hyphen: docker-compose. In 2020, Docker rewrote it in Go and folded it into the main docker command as a plugin, called with a space: docker compose. According to Docker's own documentation, that second version is what everyone means today when they say "Compose v2," and it's what ships by default on any fresh Docker install. The confusing part: Compose has since jumped to version 5 (v5.5.1 as of this writing), but that's not a new rewrite. Docker bumped the number specifically to stop it clashing with the old "version 2" and "version 3" labels used inside Compose YAML files themselves; functionally, v5 is the same Go plugin as v2, just with an official SDK added underneath (source: Docker Compose history docs).
| docker-compose (v1) | docker compose (v2/v5) | |
|---|---|---|
| Written in | Python | Go |
| Installed as | Separate binary | Plugin inside the docker CLI |
| version: key in your file | Required, checked | Ignored, just informative |
| Support status | Unsupported since June 2023 | Current, actively developed |
| Latest release | 1.29.2 (final) | 5.5.1 (September 2026) |
Docker announced the end of v1 support in June 2023, stating plainly that "Compose V1 support will no longer be provided after June 2023 and will be removed from all future Docker Desktop versions." That's not a soft suggestion; it's the vendor telling you the old program stopped receiving security patches and bug fixes years ago.
Fix A: docker compose Works, docker-compose Doesn't
This is the most common version of the error on a machine set up any time in the last couple of years, and it's also the easiest one to fix.
- Confirm the fix by rerunning your original command with a space instead of a hyphen. If you were following a guide that said
docker-compose up, typedocker compose upinstead. You should see your containers start building or pulling images, the same output you were expecting the first time. If you get the same "command not found" message, you likely have a typo somewhere else, or Docker itself isn't installed; jump to Fix D. - Update any scripts that hard-code the old hyphenated name. If it's your own project's helper script, open it and swap
docker-composefordocker composewherever it appears. You'll know it worked because the script runs without printing the error again. - If you can't edit the script (it belongs to someone else's project), add a shell alias instead. Open your shell config file (
~/.bashrcor~/.zshrc, depending on which shell you use) and add this line at the end:
alias docker-compose='docker compose'
Save the file, then run source ~/.bashrc (or restart your terminal). Typing docker-compose now silently runs docker compose instead. The catch: an alias only works in an interactive shell. If a cron job or another script calls docker-compose directly, the alias won't apply there, because non-interactive shells don't load your alias file by default.
- For scripts and cron jobs, use a tiny wrapper file instead of an alias. Create a file at
/usr/local/bin/docker-composewith this content:
#!/bin/sh
exec docker compose "$@"
Then make it executable with chmod +x /usr/local/bin/docker-compose. Now any script, cron job, or CI pipeline that calls the old hyphenated name gets quietly redirected to the plugin. If you manage several machines and want the same behavior consistently, Docker maintains an official shim for exactly this purpose called compose-switch, which wires itself up through your system's update-alternatives tool on Linux.
One note if you're on Docker Desktop (Mac or Windows): recent versions dropped the docker-compose shortcut from the app bundle entirely, so this alias or wrapper step applies there too, not just on Linux servers.
Fix B: docker-compose Works but docker compose Doesn't
If your machine answered the hyphenated command but stayed silent (or errored) on the version with a space, you're running the old v1 tool, and the new plugin was never installed alongside it. This is common on machines that haven't been touched since before 2023, or on Ubuntu installs where apt pulled in the older package by default (more on that trap in Fix C).
- Confirm you're on v1 by checking the version number. Run
docker-compose versionand look at the first line. If it starts with1., for exampledocker-compose version 1.29.2, that confirms it. - Remove the old package before installing the new plugin, so the two don't conflict. On Ubuntu or Debian, that usually means
sudo apt remove docker-compose. You'll see apt list the package it's about to remove; confirm with "y" when prompted. - Install the plugin using the steps in Fix C below, which covers the exact commands for Ubuntu and Debian.
Why bother moving off v1 if it still technically runs? Beyond the lack of security patches, the ecosystem has quietly moved on around it. GitHub removed Compose v1 from its own hosted CI runners in July 2024 and told users to switch their workflows to the spaced command, which tells you this isn't a niche preference; it's the direction the whole tooling world went (source: GitHub changelog).
Fix C: Neither Command Works on Ubuntu or Debian
If both commands failed but docker on its own works fine, you have Docker Engine installed without the Compose plugin. Here's where a lot of guides send you wrong: running sudo apt install docker-compose feels like the obvious next step, but on Ubuntu 22.04 and 24.04 that package still installs the retired v1 1.29.2, the exact Python tool Docker stopped supporting. Ubuntu's own package index confirms the plain docker-compose name still points at the old build on those releases; the current plugin lives under a different package name entirely.
Here's the install that actually gets you the current, supported tool:
- Remove any conflicting packages first, so nothing old is left behind to interfere. Run:
sudo apt remove docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker
Don't worry if apt says some of these aren't installed; it'll just skip them. That's expected, not an error.
- Add Docker's official repository and install the current packages, including the plugin. Follow the setup steps on Docker's Ubuntu installation page to add their apt repository, then run:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Notice the package name at the end: docker-compose-plugin, not docker-compose. That distinction is exactly what keeps you off the v1 trap.
- Verify the install worked by running the version check again. Type
docker compose version. You should see a v5 (or v2) version number print back. If you instead get "command not found" here, the repository probably wasn't added correctly in step 2; rerun the repository setup commands from Docker's page before trying the install again.
This is supported on the current Ubuntu LTS releases (26.04, 24.04, and 22.04), so the same three commands work regardless of which one you're on.
Fix D: docker Itself Is Missing (WSL, Raspberry Pi, VPS)
If even plain docker gave you "command not found," Compose isn't your problem yet; Docker Engine itself isn't installed or isn't reachable from where you're standing.
- On WSL (Windows Subsystem for Linux), check that Docker Desktop's integration is switched on for your distro. Open Docker Desktop on Windows, go to Settings, then Resources, then WSL Integration, and toggle on the distribution you're working in. You'll know it worked because a new terminal window in that WSL distro can now run
docker --versionsuccessfully. Without that toggle enabled, the WSL shell has no access to Docker commands at all, by design. - On a Raspberry Pi or a fresh VPS, install Docker with the official convenience script. Run:
curl -fsSL https://get.docker.com | sh
This script installs the Compose plugin alongside Docker Engine for any Docker version 20.10 or later, so you shouldn't need a separate Compose install step afterward on these machines.
- If you use sudo and still see "command not found" after installing, check where the plugin landed. A manual plugin install can end up in
~/.docker/cli-plugins, which belongs to your own user account. Root (and anything run throughsudo) looks in a different, system-wide location instead:/usr/local/lib/docker/cli-plugins. If your regular user can rundocker composefine butsudo docker composecan't find it, that per-user folder is almost always why.
The "line 1: Not: command not found" Mystery
Once in a while the error looks almost identical but slightly stranger: docker-compose: line 1: Not: command not found. That extra "line 1" is your clue that something different is going on.
What's actually happening: an old-style install script tried to download the Compose binary directly with curl, built the download URL from your system's architecture, and got the URL slightly wrong. Instead of the actual program, it saved GitHub's plain-text "Not found" error page as the binary file. That file is often just nine bytes long: the words "Not found" and a line break. Your shell tries to run it as a script, reads the first word ("Not"), and reports that "Not" isn't a command, which is technically true but not very helpful on its own. This exact scenario has shown up in real bug reports on both Docker's own forums and in project issue trackers, always tracing back to that same corrupted download.
The fix is straightforward:
- Delete the broken file. It's usually sitting at
/usr/local/bin/docker-compose. Runsudo rm /usr/local/bin/docker-compose. You'll know it's gone whenwhich docker-composereturns nothing. - Switch to the plugin instead of trying the curl download again. Use
docker composegoing forward, or install the plugin properly using Fix C above. The standalone curl install is what caused this in the first place, and Docker's own documentation describes that install path as "not recommended," supported only for backward compatibility, not as the default way to get Compose.
What Happens Next: The Obsolete version Warning
Once you've got the right command running, there's a good chance your old Compose file throws a new message at you: a warning that the top-level version key is obsolete. This is expected, and it's a much smaller problem than the one you just solved.
According to Docker's Compose Specification reference, the version line at the top of older Compose files was kept only for backward compatibility; the current tooling reads it, ignores it for any real purpose, and prints a warning telling you it's no longer needed (source: Compose Specification, version and name reference). It won't stop your stack from starting. It's just Docker nudging you to clean up a leftover from the old file format.
- Delete the version: line from the top of your file. Open the file in your editor, remove that one line, and save.
- Rename the file to compose.yaml if it's still called docker-compose.yaml. Current Compose reads
compose.yamlas its preferred default name; the old hyphenated filename still works for backward compatibility, but the plain name is what the current documentation recommends going forward.
If you'd rather not comb through the file by hand, dockercompose.tools has a free Compose validator that flags the obsolete version key along with roughly forty other common mistakes, each with a line number and a plain-language explanation of what to fix. If you're starting a file from nothing rather than patching an old one, the Compose generator writes a clean compose.yaml without the version key in the first place, so you never run into this warning at all. While you're cleaning up an inherited file, it's also worth checking whether passwords are still sitting in plain text inside it; the site's breakdown of docker compose environment variables covers .env, environment, and env_file, and the order Compose uses when more than one of them sets the same value. Once your stack is running, checking that the site or API behind it actually responds is a separate step; a tool like httpcheck.tools is handy for confirming that once docker compose up finishes, something is genuinely listening on the port you expect. The next failure mode people hit after that is a service starting before the database it depends on is actually ready; the guide to Compose healthchecks and depends_on walks through making one service wait on another instead of racing it on first boot. And if you want the fuller picture of how services, networks, and volumes fit together beyond fixing this one error, the site's general guide to using Docker Compose covers that ground.
Frequently Asked Questions
Why do I get docker-compose: command not found?
You get this message because docker-compose, with a hyphen, refers to the original Python version of Compose (v1), and any Docker install set up in the last few years doesn't include it by default. Current installs ship docker compose, with a space, as a plugin built into the main Docker command instead. The fix in almost every case is simply to add a space where the hyphen used to be, or, if you'd rather keep old scripts working unchanged, set up an alias or wrapper that quietly redirects the old name to the new one.
What is the difference between docker compose and docker-compose?
The difference is generation and packaging, not features you'd notice day to day. docker-compose (v1) was a standalone Python program you installed separately, and Docker stopped supporting it after June 2023. docker compose (v2, now renumbered to v5) is a Go-based plugin built directly into the docker command, actively maintained, and the version that ignores the old version: key in Compose files rather than requiring it. If you're setting anything up new, docker compose with a space is the one to use.
How do I install Docker Compose on Ubuntu?
Install it as a plugin, not as the plain docker-compose package, since that package still points to the outdated v1 build on Ubuntu 22.04 and 24.04. Remove any conflicting packages first with sudo apt remove docker.io docker-compose docker-compose-v2, add Docker's official apt repository following the steps on Docker's Ubuntu installation page, then run sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin. Confirm it worked with docker compose version, which should print a v5 or v2 release number.
Is docker-compose deprecated?
Yes. Docker announced in June 2023 that Compose V1 would stop receiving support and would be removed from future Docker Desktop releases, and that removal has already happened across the ecosystem: GitHub dropped v1 from its own hosted CI runners in mid-2024, and current Docker installs on any platform ship only the plugin-based docker compose by default. The hyphenated command still runs on machines where someone installed it manually or where an old distro package left it behind, but it receives no security updates and shouldn't be treated as your daily tool going forward.