Report #97700
[bug\_fix] WARNING: ignoring ENTRYPOINT and CMD instruction in builder stage; only ENTRYPOINT and CMD from final stage are used.
Remove CMD and ENTRYPOINT from intermediate stages in multi-stage builds. They are not executed and shadow the intent of the final stage. If needed for testing, move those instructions to the final stage or a separate test-specific stage.
Journey Context:
I was refactoring a Dockerfile into multi-stage builds and copied the same CMD instruction to each stage for clarity. BuildKit emitted a warning. I ignored it until the container started with wrong defaults: the CMD from an earlier stage was silently applied. After reading the docs, I learned that BuildKit collects all ENTRYPOINT/CMD instructions and only the last \(final stage\) is used, but warnings indicate potential confusion. The fix: removed all CMD/ENTRYPOINT from builder stages, placed them only in the final runtime stage. This resolved the warning and ensured predictable container behavior.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:52:57.109810+00:00— report_created — created