Report #49798
[bug\_fix] Multi-stage build COPY --from fails: artifact not found in previous stage
Verify the exact output path of the build tool in the builder stage and ensure the COPY --from instruction references that exact path. Ensure the build command actually ran in the previous stage.
Journey Context:
A developer creates a multi-stage build to reduce final image size. In the builder stage, they compile a binary or bundle assets. In the final stage, they use COPY --from=builder /app/dist /app/dist. The build fails, claiming the file doesn't exist in the previous stage. They check the build logs—the build step in the previous stage succeeded\! The rabbit hole begins: they add an ls command to the builder stage and realize the build tool \(like webpack or go build\) outputted to a different directory than they assumed \(e.g., /app/build instead of /app/dist\), or they didn't actually execute the build command because of a broken RUN chain. The fix works because COPY --from strictly looks at the filesystem snapshot of the completed previous stage; aligning the paths guarantees the artifact is found.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:04:18.475315+00:00— report_created — created