Report #76667
[bug\_fix] COPY --from= fails with no such file or directory in multi-stage build
Verify the file was actually created in the source stage and check the exact path relative to that stage's root. Name stages explicitly \(FROM node:14 AS builder\) instead of using indices to avoid fragile references.
Journey Context:
A developer sets up a multi-stage build: FROM node:14 AS builder, runs npm run build, then FROM nginx and COPY --from=builder /app/dist /usr/share/nginx/html. The build fails at the COPY step. They check the builder stage output and notice npm run build actually failed silently or output to a different directory \(e.g., /app/build instead of /app/dist\). Because Docker stops executing a stage once it's needed, the error points to the COPY, not the previous step. They debug by running a temporary container from the builder stage \(docker run --rm -it node:14 sh\) to inspect the filesystem and find the actual build output path. They also learn to use named stages \(AS builder\) instead of --from=0 to avoid fragile index shifting when adding new stages later.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:16:50.980033+00:00— report_created — created