Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

docker-compose answers with line 1: Not: command not found

Your error

/usr/local/bin/docker-compose: line 1: Not: command not found1 more line it can show

Fix it fast

Most common cause, 1 of 2

The URL asks for an OS or CPU name that Compose does not publish

Remove the broken file and download the asset whose name appears in the release list for your CPU.

Fix
sudo rm /usr/local/bin/docker-compose
VERSION=v5.8.0
ARCH=armv7   # pick one: x86_64 aarch64 armv7 armv6 ppc64le riscv64 s390x
sudo curl -fSL "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-linux-${ARCH}" \
  -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

/usr/local/bin/docker-compose: line 1: Not: command not found means the file holds the text Not Found instead of a program: curl saved GitHub's 404 page from a release URL that does not exist. Delete it and download the exact asset name (lowercase linux, armv7 not armv7l, a v before the version) with curl -f, or install docker-compose-plugin. Compose v2 to v5.8.

  • Applies to Docker Compose v5.8.0, Docker Engine 28 and 29, Raspberry Pi OS Bookworm (32-bit and 64-bit), Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Look at what the file contains and how big it is, then print the names your download command filled in. A file only a few bytes long that reads Not Found confirms a failed download; comparing the uname output and your URL with the release's asset list shows which part of the name was wrong.

Run this first
head -c 100 /usr/local/bin/docker-compose; echo
ls -l /usr/local/bin/docker-compose
uname -s; uname -m

Then find the line you see in this list and open its fix:

  1. 1The URL asks for an OS or CPU name that Compose does not publishThe URL you used contains Linux with a capital L, armv7l, arm64 or amd64, or it comes from an old 1.x guide written for a Raspberry Pi
  2. 2The version part of the URL is not a real release tagThe OS and CPU part of the name match the asset list, but the version in the URL lacks its v, carries an extra v, or is a placeholder copied from a guide

What does the error look like?

  • /usr/local/bin/docker-compose: line 1: Not: command not found
  • docker-compose: line 1: Not: command not found

Cause 1 of 2

The URL asks for an OS or CPU name that Compose does not publish

You seeThe URL you used contains Linux with a capital L, armv7l, arm64 or amd64, or it comes from an old 1.x guide written for a Raspberry Pi

Check

A release URL that names a missing file gets an HTTP 404 Not Found answer from GitHub. curl treats that as a normal transfer unless --fail is given, so -o writes the error page into /usr/local/bin/docker-compose. After chmod +x, bash cannot execute the file as a program, runs it as a shell script instead, and fails on its first word, Not. Compose v5.8.0 publishes lowercase names only: docker-compose-linux- followed by aarch64, armv6, armv7, ppc64le, riscv64, s390x or x86_64. A command built from $(uname -s)-$(uname -m) gives a matching name only when both outputs are spelled exactly like that; Compose 1.29.2 used Linux-x86_64 and had no ARM build at all.

Check
curl -sSL -o /dev/null -w '%{http_code}\n' https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-armv7

Fix

Remove the broken file and download the asset whose name appears in the release list for your CPU. Add -f, so a wrong name makes curl stop with an error instead of saving a 404 page.

Fix
sudo rm /usr/local/bin/docker-compose
VERSION=v5.8.0
ARCH=armv7   # pick one: x86_64 aarch64 armv7 armv6 ppc64le riscv64 s390x
sudo curl -fSL "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-linux-${ARCH}" \
  -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Verify

The file is now a real program, far larger than an error page, and the command prints the Compose version instead of a shell error.

Verify
ls -lh /usr/local/bin/docker-compose
docker-compose version

Confirmed by github.com

Did this fix it?

Cause 2 of 2

The version part of the URL is not a real release tag

You seeThe OS and CPU part of the name match the asset list, but the version in the URL lacks its v, carries an extra v, or is a placeholder copied from a guide

Check

Release tags changed form between Compose generations: the last 1.x release is tagged 1.29.2 with no v, while current releases are tagged like v5.8.0. A URL with 5.8.0, v1.29.2 or a literal placeholder points at a release that does not exist, and the result is the same Not Found file. Docker's own install pages tell you to substitute the version in their example URL, which makes this an easy slip.

Check
curl -sSL -o /dev/null -w '%{http_code}\n' https://github.com/docker/compose/releases/download/5.8.0/docker-compose-linux-x86_64
curl -sSL -o /dev/null -w '%{http_code}\n' https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-x86_64

Fix

Copy the tag exactly as the releases page shows it and keep -f on the download, then make the file executable.

Fix
sudo curl -fSL https://github.com/docker/compose/releases/download/v5.8.0/docker-compose-linux-x86_64 \
  -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Verify

The second check command prints 200 for your URL, and docker-compose version runs.

Verify
docker-compose version

Confirmed by docs.docker.com

Did this fix it?

How do I stop it coming back?

  • Install Compose from Docker's package repository as docker-compose-plugin and run docker compose; Docker labels the standalone binary as kept only for backward compatibility, and manual installs never update themselves.
  • Use curl -f (or -fSL) in every script that downloads a binary, so an HTTP error stops the script instead of producing a text file.
  • On a 32-bit Raspberry Pi OS, plan the move to the 64-bit OS: Docker says Engine 28 is the last major version with 32-bit armhf packages, and 64-bit users follow the Debian instructions.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Dispatch Pro.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.