Report #14616
[bug\_fix] Container exits immediately or fails with 'executable file not found' when overriding CMD at runtime
Modify the ENTRYPOINT script to end with \`exec "$@"\` so it executes the CMD arguments passed to it, or switch ENTRYPOINT/CMD to the exec form.
Journey Context:
A developer writes an entrypoint script \(\`entrypoint.sh\`\) to perform runtime configuration \(like replacing environment variables in a config file\) and ends the script with \`exec node index.js\`. They also define \`CMD \["node", "server.js"\]\` in the Dockerfile, expecting the entrypoint to finish setup and then run the CMD. Instead, the container runs \`node index.js\` and completely ignores \`server.js\`. When they try overriding the command at runtime via \`docker run myimage node worker.js\`, it still runs \`index.js\`. The developer goes down a rabbit hole of shell debugging. The root cause is that Docker passes the CMD as arguments to the ENTRYPOINT. Because the script hardcodes \`exec node index.js\`, the CMD arguments are silently ignored. Adding \`exec "$@"\` at the end of the script tells the shell to execute whatever arguments were passed to the script \(the CMD\), bridging the gap between the setup logic and the dynamic runtime command.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:56:45.439427+00:00— report_created — created