unknown shorthand flag: 'd' in -d after docker compose up -d means
the Docker CLI on that machine has no Compose plugin. In the test, an Alpine container with
only the docker-cli package, the CLI rejected the -d instead of
saying that compose was missing. After the Compose plugin was installed,
docker compose version and docker compose config worked.
The message points at the flag, but the flag is fine. docker compose version
on the same machine says what is really missing. The exit code 125 and the top-level usage
line printed with the error are the two hints that the problem sits before the flag.
The error
+ docker --version
Docker version 29.9.3, build 5457199aa57c45e990c59c89cab5f02b817238d7
+ docker compose up -d
unknown shorthand flag: 'd' in -d
Usage: docker [OPTIONS] COMMAND [ARG...]
Run 'docker --help' for more information
+ echo 'exit=125'
exit=125
Why it happens
The -d is a valid flag for docker compose up. The CLI rejected it
because it never got as far as Compose: in this container the plugins folder
/usr/libexec/docker/cli-plugins did not exist (ls said
No such file or directory). The usage line printed with the error,
docker [OPTIONS] COMMAND [ARG...], is the top-level docker one,
not a Compose usage line. The exit code was 125.
Asking for the version without a flag gives a clearer message from the same missing plugin; that case has its own page, docker: unknown command: docker compose.
The fix
apk add --no-cache docker-cli-compose
+ ls /usr/libexec/docker/cli-plugins
docker-compose
+ docker compose version
Docker Compose version v5.6.1
+ echo 'exit=0'
+ docker compose config
exit=0
name: work
services:
web:
image: alpine
...
With the plugin in place, docker compose config read the same
compose.yaml that up -d had been pointed at and printed it back,
so the subcommand and its arguments now reach Compose. The container had no Docker engine,
and up -d was not run again after the fix; on a machine with an engine, that is
the next command to try.
How it was reproduced
A shell script with set -x ran in an alpine container of the
test's own: it installed Alpine's docker-cli package (Docker 29.9.3), wrote a
three-line compose.yaml with one web service and ran
docker compose up -d. The same script, in its first run, went on to install
docker-cli-compose (Docker Compose v5.6.1) and run the checks shown under the
fix. The lines that start with + are the shell's trace.
Frequently asked
- Why does docker compose up -d say unknown shorthand flag 'd'?
- In the test the Docker CLI had no Compose plugin. It printed the top-level docker usage with this message and exit code 125; docker compose version on the same CLI printed docker: unknown command: docker compose.
- How do I install the Docker Compose plugin on Alpine?
- apk add docker-cli-compose. In the test it put docker-compose into /usr/libexec/docker/cli-plugins and docker compose version printed Docker Compose version v5.6.1.
- How do I check whether the Docker Compose plugin is installed?
- Run docker compose version. With the plugin it prints the Compose version; without it the CLI printed docker: unknown command: docker compose and exited with 1.
More decoded errors in the Fixes category. If your command is the older hyphenated form, see docker-compose: command not found.