Report #597
[bug\_fix] Container exits immediately on \`docker run\` with \`Error response from daemon: No command specified\` or runs \`/bin/sh -c\` instead of the intended binary.
Use the exec form \`ENTRYPOINT \["executable"\]\` for the fixed command and exec form \`CMD \["default", "args"\]\` for defaults. Runtime arguments to \`docker run args...\` override \`CMD\`, not \`ENTRYPOINT\`. Avoid mixing shell-form ENTRYPOINT with exec-form CMD because the shell form wraps the command in \`/bin/sh -c\` and may drop or mis-handle arguments.
Journey Context:
I had a Go HTTP server image. The Dockerfile ended with \`ENTRYPOINT /server\` and \`CMD \["--port", "8080"\]\`. When I ran \`docker run myimage --port 9090\`, the container exited instantly. \`docker inspect\` showed the command was \`/bin/sh -c '/server' --port 9090\`, so the \`--port\` argument was passed to \`sh\`, not to \`/server\`. I had misunderstood the interaction between ENTRYPOINT and CMD. In the exec form, CMD supplies default arguments to ENTRYPOINT and \`docker run\` arguments replace CMD. In the shell form, ENTRYPOINT runs as a shell command and CMD is ignored unless you explicitly reference \`$@\`. I changed both to exec form: \`ENTRYPOINT \["/server"\]\` and \`CMD \["--port", "8080"\]\`. Then \`docker run myimage --port 9090\` correctly invoked \`/server --port 9090\`. The fix works because the exec form passes the JSON array directly to \`execve\`, preserving the intended executable and argument vector.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T09:57:25.336924+00:00— report_created — created