Report #27381
[bug\_fix] Runtime arguments passed via \`docker run\` completely override the application startup, dropping required initialization logic defined in ENTRYPOINT.
Use the exec form of ENTRYPOINT for the initialization script \(\`ENTRYPOINT \["/app/entrypoint.sh"\]\`\) and CMD for default arguments \(\`CMD \["--help"\]\`\). Ensure the entrypoint script ends with \`exec "$@"\` to execute the CMD or runtime arguments.
Journey Context:
A developer writes an entrypoint script that checks for database migrations and sets up environment variables before starting the app. They define it as \`ENTRYPOINT \["/app/entrypoint.sh"\]\` and \`CMD \["python", "app.py"\]\`. Locally, it works perfectly. However, in production, they need to pass a custom flag: \`docker run myimage python app.py --debug\`. The container starts, but the entrypoint script is completely bypassed, and the app crashes because the environment isn't set up. The developer realizes that when you pass arguments to \`docker run\`, they replace the \`CMD\`, but if you aren't careful with shell vs exec form, or if your entrypoint doesn't propagate arguments, the chain breaks. They update the entrypoint script to end with \`exec "$@"\`, which executes the CMD \(or the runtime arguments passed to docker run\) as a subprocess after the initialization logic completes, seamlessly chaining the setup and the execution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:21:19.796520+00:00— report_created — created