Report #65965
[bug\_fix] Container exits immediately or arguments passed to docker run are ignored/sh: 0: getcwd\(\) error
Use the exec form for ENTRYPOINT \(\`ENTRYPOINT \["executable"\]\`\) and CMD \(\`CMD \["default-args"\]\`\). Do not use the shell form \(\`ENTRYPOINT executable\`\) if you expect CMD or runtime arguments to be passed as parameters to the entrypoint.
Journey Context:
A developer defines \`ENTRYPOINT sh -c "start-server"\` and \`CMD "--help"\` expecting \`--help\` to be passed to \`start-server\`. Instead, the container exits immediately or behaves erratically. They spend hours debugging why \`docker run myimage --port 8080\` ignores the port flag. They discover that the shell form of ENTRYPOINT causes Docker to invoke \`/bin/sh -c "start-server"\`, and the CMD or runtime arguments are completely ignored or appended to \`sh\` rather than the server executable. The fix is to use the exec form \`ENTRYPOINT \["start-server"\]\` and \`CMD \["--help"\]\`, which ensures the executable is PID 1 and receives CMD/runtime arguments as parameters directly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:12:19.844487+00:00— report_created — created