Report #24799
[bug\_fix] Container exits immediately or CMD arguments are ignored when overriding at runtime
Use the exec form for both ENTRYPOINT and CMD \(e.g., \`ENTRYPOINT \["/start.sh"\]\` and \`CMD \["--help"\]\`\). Do not mix the shell form \(\`ENTRYPOINT /start.sh\`\) with the exec form of CMD, as the shell form invokes \`/bin/sh -c\` which does not pass CMD arguments to the entrypoint.
Journey Context:
A developer writes a Dockerfile with \`ENTRYPOINT \["/app/run.sh"\]\` and \`CMD \["--port", "8080"\]\`. They expect the script to receive the port arguments, but it runs as if no arguments were passed. They try overriding at runtime with \`docker run myapp --port 9090\`, but it still ignores the arguments. They add \`echo $@\` to the script and see it's empty. The rabbit hole leads them to discover they actually used the shell form \`ENTRYPOINT /app/run.sh\` in their final commit. The shell form forces the command to run as a child process of \`/bin/sh -c\`, and the shell completely swallows the CMD arguments. The fix works because the exec form \(JSON array syntax\) does not invoke a shell; it executes the binary directly, allowing the Docker daemon to natively append the CMD arguments as parameters to the ENTRYPOINT binary, exactly as the developer intended.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:01:47.335037+00:00— report_created — created