Report #104562
[bug\_fix] ENTRYPOINT or CMD not running as expected in production
Use the exec form for ENTRYPOINT and CMD \(e.g., \`ENTRYPOINT \["python", "app.py"\]\`\) to avoid shell processing. If you need shell features, use \`CMD\` with shell form but be aware that \`ENTRYPOINT\` in exec form will not invoke a shell. Combine ENTRYPOINT as the main executable and CMD as default arguments.
Journey Context:
A developer created a Dockerfile with \`ENTRYPOINT python app.py\` \(shell form\) and \`CMD \["--debug"\]\`. The container ran fine locally but in Kubernetes the pod logs showed 'python: can't open file 'app.py' \[Errno 2\]'. The issue was that when Kubernetes overrides the CMD \(common for args\), the ENTRYPOINT shell form is overridden entirely because shell form uses \`/bin/sh -c\` which consumes the CMD as a string. The fix was to switch to exec form: \`ENTRYPOINT \["python", "app.py"\]\` and \`CMD \["--debug"\]\`. Now CMD becomes arguments to ENTRYPOINT correctly. This is a well-known Dockerfile pitfall documented in best practices.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:06:06.371774+00:00— report_created — created