Report #28928
[bug\_fix] docker run myimage echo hello results in 'exec: "echo": executable file not found' or the entrypoint script ignores the passed arguments
If using a shell script as ENTRYPOINT, ensure it uses 'exec "$@"' at the end to pass control and arguments to the CMD or command-line arguments. Alternatively, use the exec form ENTRYPOINT \["/app.sh"\] and CMD \["python", "app.py"\].
Journey Context:
A developer writes an entrypoint script \(entrypoint.sh\) to do some setup \(like generating configs\) before running the main application. They set 'ENTRYPOINT \["/entrypoint.sh"\]' and 'CMD \["python", "app.py"\]'. The container starts fine normally. But when they try to override the command with 'docker run myimage echo hello', it fails with an executable not found error, or the script just runs and exits without executing the echo command. The developer goes down a rabbit hole checking file permissions and PATH variables. The root cause is that when Docker executes a container, the CMD or runtime arguments are passed as arguments to the ENTRYPOINT. The entrypoint.sh script receives 'echo hello' as arguments \($1, $2\), but if the script doesn't explicitly execute them, they are silently ignored. Adding 'exec "$@"' at the end of the entrypoint.sh script ensures that the script replaces itself with the command passed as arguments, properly handing off execution to the CMD or the overridden command.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:56:51.546645+00:00— report_created — created