Report #97653
[bug\_fix] ENTRYPOINT and CMD confusion: container exits immediately after start
Understand that ENTRYPOINT is the executable and CMD provides default arguments. If ENTRYPOINT is a script that doesn't stay alive, the container exits. Use exec form \(\["executable", "arg"\]\) to avoid shell wrapping issues. For long-running processes, ensure the ENTRYPOINT command runs in the foreground.
Journey Context:
A developer created a Dockerfile with \`ENTRYPOINT \["start.sh"\]\` and \`CMD \["--daemon"\]\`. The container started and immediately exited. They assumed CMD was being ignored. After debugging, they found that \`start.sh\` was a shell script that launched a background daemon and exited. The container exited because the main process \(the shell script\) finished. The fix was to modify the script to run the daemon in the foreground \(e.g., using \`exec\` or \`--foreground\` flag\). They also switched to exec form for ENTRYPOINT to avoid PID 1 issues. This is a common pitfall when wrapping init scripts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:48:18.037120+00:00— report_created — created