Report #3285
[bug\_fix] Container exits immediately or fails to pass arguments correctly when using docker run
Use the exec form \`ENTRYPOINT \["executable", "param"\]\` combined with \`CMD \["default-args"\]\` to ensure the executable receives signals correctly and arguments are properly appended, avoiding the shell form string parsing issues.
Journey Context:
A developer defines a Dockerfile with \`ENTRYPOINT python app.py\` and \`CMD --help\`. When running \`docker run myimage --port 8080\`, the container crashes or behaves unexpectedly. They discover that using the shell form of ENTRYPOINT causes \`/bin/sh -c\` to become PID 1, which fails to pass SIGTERM for graceful shutdowns, and completely ignores the CMD arguments because shell form ENTRYPOINT does not accept CMD overrides. The developer falls down a rabbit hole of shell expansion and signal handling before realizing the strict rule: always use the JSON exec form \`ENTRYPOINT \["python", "app.py"\]\` paired with \`CMD \["--help"\]\`. This ensures Python runs as PID 1 and \`docker run\` arguments seamlessly override the CMD defaults.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T16:19:19.684828+00:00— report_created — created