Report #41424
[bug\_fix] exec format error or executable file not found in $PATH when passing runtime arguments to a container
Use \`ENTRYPOINT\` for the executable and \`CMD\` for default arguments, or use an entrypoint script that processes arguments via \`exec "$@"\`. Do not combine \`ENTRYPOINT\` and \`CMD\` as full commands.
Journey Context:
A developer defines \`ENTRYPOINT \["python", "app.py"\]\` in their Dockerfile. They want to debug the container by running \`docker run myimage bash\`. Instead of a bash shell, the container crashes with a Python error like \`python: can't open file 'bash'\`. The developer thinks bash is missing from the image and spends time installing it, only to get the same error. The root cause is the interaction between \`ENTRYPOINT\` and \`CMD\`. When both are defined in exec form, \`CMD\` is passed as arguments to \`ENTRYPOINT\`. So \`docker run myimage bash\` appends \`bash\` as an argument to \`python app.py\`. The fix is to separate the binary from the default arguments: \`ENTRYPOINT \["python"\]\` and \`CMD \["app.py"\]\`. Now, \`docker run myimage bash\` correctly overrides \`CMD\` and runs \`python bash\` \(or better, they use an entrypoint script with \`exec "$@"\` to handle argument passthrough properly\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T00:00:13.383837+00:00— report_created — created