Report #70933
[bug\_fix] COPY --from=0 failed: file not found in build \(Multi-stage build path issues\)
Ensure the source path in COPY --from= is the absolute path from the root of the previous stage's filesystem, not relative to the WORKDIR of the current stage, and not relative to the WORKDIR of the previous stage unless explicitly starting from it.
Journey Context:
A developer sets up a multi-stage build. In the builder stage, they set WORKDIR /app and compile an application, outputting files to /app/dist. In the final stage, they set WORKDIR /app and attempt COPY --from=builder dist ./dist. The build fails with 'file not found'. They are confused because the file exists in the builder stage. They eventually realize that COPY --from requires the path to be resolved from the root of the source stage's filesystem, independent of the current stage's WORKDIR. Because WORKDIR in the builder stage was /app, the absolute path is /app/dist. Changing the instruction to COPY --from=builder /app/dist ./dist resolves the issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:38:28.951838+00:00— report_created — created