Home › Docker

unknown shorthand flag: 'd' in -d (Docker) — how to fix

$ docker compose up -d
unknown shorthand flag: 'd' in -d
See 'docker --help'.

Quick fix: Check docker compose version. If it fails, install the plugin (sudo apt-get install docker-compose-plugin from Docker's apt repo) or use the standalone docker-compose up -d. For other commands, put flags after the subcommand: docker run -d nginx, not docker -d run nginx.

What it means

The Docker CLI is built from subcommands: docker run, docker exec, docker compose and so on. Flags belong to a subcommand. When Docker doesn't know the word after docker, it doesn't treat it as a subcommand, and the following flags are parsed as global docker flags. docker has no -d flag, so you get unknown shorthand flag: 'd' in -d.

The same pattern gives unknown shorthand flag: 'f' in -f (docker compose -f file.yml up) or unknown flag: --build.

Cause 1: the Compose v2 plugin is missing

docker compose (with a space) is a CLI plugin. If it's not installed, compose is unknown:

docker compose version

If that prints docker: 'compose' is not a docker command. or the help text, install the plugin.

Ubuntu/Debian with Docker's official repository:

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

Fedora/RHEL/CentOS with Docker's repository:

sudo dnf install docker-compose-plugin

Ubuntu's own docker.io package doesn't use Docker's repo; on recent Ubuntu releases the plugin is packaged as docker-compose-v2:

sudo apt-get install docker-compose-v2

Manual install (any Linux): download the docker-compose binary for your architecture from the docker/compose GitHub releases page and put it in the CLI plugins folder:

mkdir -p ~/.docker/cli-plugins
mv docker-compose-linux-x86_64 ~/.docker/cli-plugins/docker-compose
chmod +x ~/.docker/cli-plugins/docker-compose
docker compose version

Docker Desktop (Windows/macOS) includes Compose v2. If it's missing there, update Docker Desktop.

Cause 2: you only have the old standalone docker-compose

Compose v1 was a separate program named docker-compose (with a hyphen). If that's what you have, use the hyphen:

docker-compose up -d

Compose v1 is no longer maintained, so installing the v2 plugin is the better long-term fix. Scripts and CI pipelines that use docker compose need the plugin on that machine too.

Cause 3: flags before the subcommand

Order matters:

docker -d run nginx             # wrong
docker run -d nginx             # right

docker -it exec web sh          # unknown shorthand flag: 'i' in -it
docker exec -it web sh          # right

For Compose, global options like -f and -p go between compose and the subcommand, and command options go after it:

docker compose -f compose.prod.yml -p myapp up -d --build

Cause 4: a typo in the subcommand

docker compsoe up -d, docker buildx without the buildx plugin, or a pasted command with a non-breaking space or an en dash (–d instead of -d) produce the same kind of error. Retype the command by hand if it was copied from a web page or document.

Check what's installed

docker version
ls ~/.docker/cli-plugins /usr/libexec/docker/cli-plugins 2>/dev/null

To turn a long docker run command into a Compose file, use the docker run to Compose converter.

Last updated 2026-11-29.