Fix 'unknown shorthand flag: d' in Docker Compose: Offline v2 Install Guide
This guide resolves the 'unknown shorthand flag: d' error when running docker compose up -d on air-gapped servers by detailing the complete offline installation of Docker Compose v2, including architecture verification, binary download with checksum validation, upload via scp, placement in cli-plugins directories, symlink creation for legacy docker-compose compatibility, verification steps, and troubleshooting seven common pitfalls.
Reading font

Problem: "unknown shorthand flag: 'd' in -d"
On air-gapped servers with newer Docker, running docker compose up -d fails with unknown shorthand flag: 'd' in -d. The command exists but rejects the -d flag. This is not a YAML syntax issue; it indicates the installed Compose is too old (distro-bundled or Python-based v1) and incompatible with Docker's CLI plugin mechanism.
Two common symptoms: docker-compose: command not found — binary missing entirely docker compose version works but up -d fails — outdated v1 plugin
Solution: install a Compose v2.x binary into Docker's cli-plugins directory.
1. Verify Environment
docker -v # 20.10+ recommended; Docker 29 needs compose v2.40+
uname -m # x86_64 or aarch64/arm64
docker compose version # optional: check existing versionDo not skip uname -m . Download the matching binary: x86_64 →
docker-compose-linux-x86_64aarch64or arm64 → docker-compose-linux-aarch64 Wrong architecture yields cannot execute binary file or exec format error, often misdiagnosed as file corruption.
2. Download Locally (with checksum)
Pin a specific version (e.g., v2.29.7); avoid latest for reproducibility.
Direct from GitHub:
VER=v2.29.7
curl -fL -o docker-compose-linux-x86_64 \
https://github.com/docker/compose/releases/download/${VER}/docker-compose-linux-x86_64If GitHub is blocked, use a mirror (e.g., ghfast.top):
curl -fL -o docker-compose-linux-x86_64 \
https://ghfast.top/https://github.com/docker/compose/releases/download/${VER}/docker-compose-linux-x86_64Verify integrity (takes one minute, saves hours of debugging):
curl -fL -o checksums.txt \
https://github.com/docker/compose/releases/download/${VER}/checksums.txt
grep docker-compose-linux-x86_64 checksums.txt | sha256sum -c -Output must show docker-compose-linux-x86_64: OK.
3. Upload to Server
From local machine (not the server):
scp docker-compose-linux-x86_64 user@SERVER_IP:/tmp/Or use sftp put. Place in /tmp/ as staging.
Confirm size on server: ls -lh /tmp/docker-compose-linux-x86_64 v2.x binary is ~60 MB. Significantly smaller means incomplete transfer.
4. Install: Two Methods
Docker CLI scans fixed directories for docker-* plugins. Choose based on distribution.
Method 1: Direct to cli-plugins (recommended for new systems)
mkdir -p /usr/local/lib/docker/cli-plugins
mv /tmp/docker-compose-linux-x86_64 /usr/local/lib/docker/cli-plugins/docker-compose
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
docker compose versionRequirements:
Directory must be named cli-plugins File must be named docker-compose (no version suffix)
Method 2: /usr/local/bin + symlink (for CentOS, Kylin, or legacy script compatibility)
sudo mv /tmp/docker-compose-linux-x86_64 /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo mkdir -p /usr/libexec/docker/cli-plugins
sudo ln -sf /usr/local/bin/docker-compose /usr/libexec/docker/cli-plugins/docker-composeEnables both invocation styles:
docker-compose version # v1 style
docker compose version # v2 plugin styleOld scripts using docker-compose and new docs using docker compose both work without conflict.
Selection Guide
Fresh machine, only new scripts → Method 1 (cleaner)
Existing scripts call docker-compose → Method 2 (dual compatibility) unknown command but file exists → try /usr/libexec/docker/cli-plugins or ensure Docker ≥ 20.10
Criterion: if the command runs, the path is correct.
5. Verify Installation
docker-compose version
docker compose version
docker versionFirst two must output Docker Compose version v2.x.x. docker version must show both Client and Server; only Client means daemon connection issue (separate problem).
6. One-Liner Script (post-upload)
sudo mkdir -p /usr/local/lib/docker/cli-plugins && \
sudo mv /tmp/docker-compose-linux-x86_64 /usr/local/lib/docker/cli-plugins/docker-compose && \
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose && \
sudo mkdir -p /usr/libexec/docker/cli-plugins && \
sudo ln -sf /usr/local/lib/docker/cli-plugins/docker-compose /usr/libexec/docker/cli-plugins/docker-compose && \
docker compose version && docker-compose versionBoth version commands succeed → done. Both plugin paths populated, legacy and modern commands work.
7. Seven Common Pitfalls
Permission denied : missing chmod +x or file not in PATH.
cannot execute binary file / exec format error : wrong architecture; re-download correct binary.
docker compose reports unknown command : plugin directory wrong; try /usr/libexec/docker/cli-plugins or verify Docker ≥ 20.10.
unknown shorthand flag: 'd' in -d : still running old version; reinstall per this guide.
docker-compose: command not found : /usr/local/bin not in PATH; check echo $PATH or use absolute path.
File size mismatch : transfer corruption; verify with official sha256sum against checksums.txt.
SELinux permission errors : run sudo restorecon -v /usr/local/bin/docker-compose to fix context.
Summary
unknown shorthand flag: 'd'is a version mismatch, not a YAML error.
Run uname -m before downloading; wrong arch wastes time.
Installation = three steps: rename to docker-compose, place in cli-plugins, chmod +x.
For legacy script support, add symlink to /usr/libexec/docker/cli-plugins.
Always verify with official checksums.txt; one minute prevents half-hour mysteries.
After Compose works, the next hurdle on air-gapped servers: up -d runs but stalls at Pulling because no images exist locally. The next article covers moving images into an offline environment.
About this article
For attribution, corrections or content rights, contact