Report #54395
[bug\_fix] COPY failed: stat /path/in/stage: file does not exist when using COPY --from=builder.
Ensure the source path in COPY --from is an absolute path starting from the root of the source stage's filesystem \(e.g., /app/dist\), not a relative path or relative to the WORKDIR.
Journey Context:
A developer sets up a multi-stage build. In the builder stage, they set WORKDIR /app and run npm run build, which outputs to ./dist. In the final stage, they write COPY --from=builder dist /app/dist, expecting it to resolve relative to the builder's WORKDIR. The build fails with file does not exist. They spend time execing into intermediate containers and checking if the build step actually generated files. The confusion stems from the fact that standard COPY \(from the context\) resolves relative to the context root, but COPY --from resolves paths absolutely from the root of the specified stage's filesystem, ignoring WORKDIR. Changing it to COPY --from=builder /app/dist /app/dist fixes the build because it uses the correct absolute path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:47:56.459997+00:00— report_created — created