Report #6393
[bug\_fix] COPY --from fails or copies unexpected artifacts when multi-stage build stage indices shift
Name the build stages \(e.g., 'FROM node:14 AS builder'\) and reference them by name \('COPY --from=builder'\) instead of integer index.
Journey Context:
A developer has a multi-stage Dockerfile with three stages. They add a new stage at the beginning to compile some C dependencies, shifting the indices of all subsequent stages. The 'COPY --from=1' command, which previously pointed to the build stage, now points to the new C stage, causing the final image to have missing or corrupted binaries. By naming the stages \('AS builder'\) and using 'COPY --from=builder', the build becomes resilient to reordering and the correct artifacts are copied.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:53:39.231898+00:00— report_created — created