Report #85226
[bug\_fix] exec: "": executable file not found in $PATH \(exit code 127\)
Use the exec form for both ENTRYPOINT and CMD \(JSON array syntax\) so that arguments are passed correctly to the executable. If using a shell script as an entrypoint, ensure it uses \`exec "$@"\` to invoke the passed command, or switch CMD to provide default flags rather than an executable.
Journey Context:
A developer defines a Dockerfile with \`ENTRYPOINT \["my-app"\]\` and \`CMD \["--help"\]\`. It builds and runs fine. However, when they run the container in production with \`docker run my-app --port 8080\`, it crashes with \`exec: "--port": executable file not found\`. They dive into shell scripting, trying to wrap the command in \`/bin/sh -c\`, which breaks signal handling \(causing the container to ignore SIGTERM\). The root cause is a misunderstanding of how Docker combines ENTRYPOINT and CMD. In exec form, the CMD array is appended directly to the ENTRYPOINT array. Because \`my-app\` is the executable, passing \`--port\` works. But if the developer had mistakenly used shell form \`ENTRYPOINT my-app\`, Docker ignores CMD entirely. If they used \`ENTRYPOINT \["/bin/sh", "-c"\]\`, then \`--port\` gets interpreted as the shell command itself, causing the 127 error. The fix is strictly using \`ENTRYPOINT \["my-app"\]\` and \`CMD \["--port", "8080"\]\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:38:16.653783+00:00— report_created — created