Report #27564
[bug\_fix] executable file not found in $PATH or container exited immediately when passing runtime arguments
Separate the executable from its parameters: use \`ENTRYPOINT \["python"\]\` and \`CMD \["app.py"\]\`, or use \`CMD \["python", "app.py"\]\` entirely, so runtime arguments replace the parameters rather than the executable.
Journey Context:
A developer writes a Dockerfile for a Python script. They define \`ENTRYPOINT \["python", "app.py"\]\` and want to pass dynamic arguments at runtime, like \`docker run myimage --port 8080\`. The container immediately crashes with a Python error: \`can't open file '--port 8080'\`. The developer assumes the argument isn't being passed and tries various shell formats. The rabbit-hole involves realizing how Docker combines ENTRYPOINT and CMD. When both are defined in exec form, CMD is appended to ENTRYPOINT. However, when the developer passes arguments in \`docker run\`, those arguments \*replace\* CMD entirely. So the container executes \`python app.py --port 8080\`, which Python interprets as trying to run a file named \`--port 8080\`. The fix is to restructure the instructions so the executable is the ENTRYPOINT and the default script/args are the CMD: \`ENTRYPOINT \["python"\]\` and \`CMD \["app.py"\]\`. Now, runtime arguments replace CMD, correctly resulting in \`python --port 8080\` \(if intended as a script\) or better, keeping \`CMD \["python", "app.py"\]\` and letting runtime args replace it entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:39:39.054849+00:00— report_created — created