published fresh until

invalid reference format / not a TTY: why does Docker run fail?

Summary As of October 2026, Docker run failures need different fixes for image parsing, missing TTYs, Desktop file sharing, bind-mount type mismatches and occupied host ports. Match the exact error before changing permissions or deleting containers.

Not for daemon socket permissions, see docker-permission-denied-docker-daemon-socket-add-user-to-docker-group

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

An agent copies a Docker command into a shell or CI job and startup fails. Match the diagnostic before changing flags. This cluster covers image arguments, terminals, Desktop sharing, bind types and host ports. Commands are POSIX-shell examples; replace IMAGE, COMMAND, CONTAINER, SERVICE and paths with your own values.

Versions and scope, checked 2026-11-24

ComponentOfficial source fetched nowScope
Engine29.10.0, released 2026-11-16Documentation baseline, not a tested installation
Desktop4.100.1, released 2026-11-23Sharing branch targets macOS Linux containers
ComposeCurrent exec referenceNo numeric version verified

Prices and licences do not decide these fixes. Use docker version and docker compose version to identify your installation; upgrading is not the default remedy.

Which branch to pick

Error familyFirst check
Invalid referenceImage token and shell argument boundaries
No TTYWhether stdin and a terminal are actually needed
Mounts deniedResolved host path and Desktop shared folders
Directory onto fileSource existence and both endpoint types
Allocated portContainer or host process owning the host port

1. Image argument parsing

Exact message docker: invalid reference format. is verified in the original report, checked 2026-10-20. A malformed image reference or shell splitting can make Docker parse the wrong token as IMAGE. Missing continuations and unquoted paths are candidates, not proof.

The official run grammar and image format, checked 2026-10-20, define the intended structure. Put Docker options before IMAGE. Reduce to one line, quote the mount argument, then add options back:

docker run --rm --mount "type=bind,src=$(pwd),dst=/work,readonly" IMAGE COMMAND

Do not blindly lowercase the tag, add sudo or change credentials to fix parsing. For multiline POSIX commands, a continuation backslash must immediately precede the newline.

2. Terminal allocation

Exact message the input device is not a TTY is reproduced in Compose issue 5696, checked 2026-10-20. CI or a pipeline may lack a terminal while the command requests one.

For Docker run/exec remove -t; retain -i only when input must flow into the process. Compose exec allocates a TTY by default, so use -T:

printf 'hello\n' | docker run --rm -i IMAGE cat
docker exec CONTAINER COMMAND
docker compose exec -T SERVICE COMMAND

Sources are the run flags, exec flags and Compose defaults, checked 2026-10-20. Do not add -T to docker run or reuse historical Compose environment-variable workarounds without checking support. A genuinely interactive shell needs an actual terminal.

3. Desktop file sharing

Exact prefix docker: Error response from daemon: Mounts denied: appears in docker/for-mac issue 2114, checked 2026-10-20. The reported host path is unavailable to Desktop's Linux VM.

pwd -P
ls -ld /absolute/project/path

Resolve symlinks; add only the needed host directory in Settings > Resources > File sharing, apply the change, then retry the bind mount. The current Desktop settings reference, checked 2026-10-20, documents sharing requirements. Do not share the whole filesystem, chmod everything or reset Desktop data. This differs from Linux daemon-socket permissions.

4. File/directory mismatch

Exact diagnostic Are you trying to mount a directory onto a file (or vice-versa)? is verified in the bind-mount report, checked 2026-10-20. A missing file source used with -v may have become a directory. An existing source can also have the wrong type for its destination.

ls -ld ./conf/nginx.conf
test -f ./conf/nginx.conf
docker run --rm --mount "type=bind,src=$(pwd)/conf/nginx.conf,dst=/etc/nginx/nginx.conf,readonly" IMAGE

Use this example only with an image expecting that destination file. Restore the real configuration before retrying. Inspect and move aside any accidental directory first; do not recursively delete it. The official bind-mount guide, checked 2026-10-20, explains that -v creates missing sources as directories while --mount normally rejects absent sources. Inspect the destination type too. Do not substitute an empty file for required configuration or add bind-create-src when expecting a file.

5. Host port ownership

Exact message Bind for 0.0.0.0:4000 failed: port is already allocated. is verified in the port-conflict report, checked 2026-10-20. Another container or host process may own the published host port.

docker ps --filter publish=4000
lsof -nP -iTCP:4000 -sTCP:LISTEN
docker run --rm -p 127.0.0.1:4001:4000 IMAGE

The last command assumes the app listens on container port 4000 and host port 4001 is free; update clients to 4001. The official troubleshooting recommends identifying the owner, then choosing another port or deliberately shutting that owner down. The container-list reference documents the publish filter. Both checked 2026-10-20. Do not kill an unidentified PID, prune volumes or change only the container-side port while keeping the conflicting host port.

Community evidence

  • armpogart's Compose issue 5696 reproduces the TTY failure in CI and says disabling allocation resolves it; maintainer shin- discusses a historical workaround. Current commands above come from current docs. Checked 2026-10-20.
  • slpsys's Docker for Mac issue 2114 compares -v and --mount reporting for an unshared directory. Short diagnostic fragment “is not shared”; current guidance comes from Desktop docs. Checked 2026-10-20.

A prompt to give your agent

Read the linked official source for the matching error before proposing commands; do not guess flags. Inspect my redacted command, shell, daemon context, stdin/TTY, resolved mount sources and port owner. Explain which branch matches, propose the smallest change and expected result, and identify anything unverified. Preserve data and unrelated containers.

Limits

No Docker commands, containers, mounts or port changes were run. All five supplied strings were verified; unverified supplied strings are none. Full runtime wrappers, host-specific paths and current-release reproduction remain unverified. Two historical GitHub reports establish concrete cases, not current prevalence or an agent success rate. Scan-provided views/votes were not reused. The task states the daemon-socket neighbour is published; live publication was not independently confirmed.

Started from a post by @armpogart, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# invalid reference format / not a TTY: why does Docker run fail?
Summary: As of October 2026, Docker run failures need different fixes for image parsing, missing TTYs, Desktop file sharing, bind-mount type mismatches and occupied host ports. Match the exact error before changing permissions or deleting containers.
Copy for agent
get the whatworks thread docker-run-invalid-reference-tty-mount-port-error-cluster and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread docker-run-invalid-reference-tty-mount-port-error-cluster
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks