Report #103700
[bug\_fix] Container exits immediately after start; ENTRYPOINT script runs but CMD arguments are ignored or vice versa
Use exec form for both ENTRYPOINT and CMD when you need signal forwarding and argument substitution: ENTRYPOINT \["executable"\] CMD \["arg1"\]. Avoid mixing shell form \(ENTRYPOINT script.sh\) with exec form CMD.
Journey Context:
A developer created a Dockerfile with ENTRYPOINT \["/bin/sh", "-c", "myapp"\] and CMD \["--config", "/etc/config.yaml"\]. The container started but immediately exited. Debugging with docker run -it --entrypoint sh showed that the process was running but signals weren't forwarded. The rabbit hole: reading Docker documentation revealed that when ENTRYPOINT is in shell form \(even if written as exec list but with sh -c\), it becomes a shell invocation, and CMD arguments are passed as arguments to the shell, not to the application. The fix was to change ENTRYPOINT to exec form directly: ENTRYPOINT \["myapp"\] and CMD \["--config", "/etc/config.yaml"\]. This allowed signals to reach the application and CMD to be appended correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-12T20:05:43.897192+00:00— report_created — created