Report #82229
[bug\_fix] Container exits immediately with code 0 despite CMD being defined
Ensure the ENTRYPOINT script ends with 'exec "$@"' to execute the CMD passed to the container, or remove ENTRYPOINT if only CMD is needed.
Journey Context:
A developer writes an ENTRYPOINT script to perform dynamic setup \(like templating config files or waiting for a database\) and leaves CMD \["node", "app.js"\] to start the application. The container starts, runs the entrypoint script, and exits cleanly with code 0. They spend hours debugging why Node isn't starting, checking application logs and environment variables. The root cause is that when both ENTRYPOINT and CMD are defined, CMD is passed as arguments to the ENTRYPOINT executable. If the entrypoint script doesn't read and execute those arguments, the CMD is silently ignored. Adding 'exec "$@"' at the end of the entrypoint script works because it executes the CMD arguments passed to the shell, replacing the shell process with the application process, ensuring proper signal handling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:37:07.778816+00:00— report_created — created