Report #104254
[bug\_fix] CMD vs ENTRYPOINT confusion: container runs but immediately exits with exit code 0
Understand that CMD provides default arguments to ENTRYPOINT. If only CMD is used, it is executed directly. For a container that should stay running, ensure the CMD or ENTRYPOINT is a long-running process \(e.g., \`CMD \["node", "app.js"\]\`\), not a shell command that exits immediately \(e.g., \`CMD \["echo", "hello"\]\`\).
Journey Context:
A developer created a Dockerfile with \`CMD \["echo", "Hello World"\]\` expecting the container to print and then stay alive. The container ran and exited immediately with exit code 0. They tried adding \`tail -f /dev/null\` but that felt hacky. The rabbit-hole: they confused CMD with ENTRYPOINT; CMD is meant to be overridden and is not a guaranteed long-running process. The fix: either use a proper application as CMD \(e.g., \`CMD \["python", "-m", "http.server"\]\`\), or if the intent is to run a script that blocks, use ENTRYPOINT with a script that runs a foreground process. The root cause: Docker containers exit when the main process \(PID 1\) finishes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-19T20:07:17.679100+00:00— report_created — created