Report #9744
[bug\_fix] COPY --from=builder fails with 'file not found' in multi-stage build
Ensure the source path in \`COPY --from=\` is the exact absolute path from the root of the previous stage's filesystem, as COPY ignores the WORKDIR of the source stage.
Journey Context:
A developer sets up a multi-stage build. Stage 1 \(builder\) compiles a Go binary. The Dockerfile has \`WORKDIR /app\` and \`RUN go build -o myapp .\`. Stage 2 does \`COPY --from=builder /myapp /usr/local/bin/myapp\`. The build fails with 'file not found'. The developer assumes the binary is in the root directory because they didn't prefix the output path, or they assume WORKDIR applies to the COPY source. They debug by running an interactive container from the builder stage \(\`docker run --entrypoint sh builder\_image\`\) and listing files, discovering the binary is actually at \`/app/myapp\`. The fix works because \`COPY --from\` uses absolute paths from the root of the source stage's filesystem, ignoring the \`WORKDIR\` setting for the source path resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:53:24.205617+00:00— report_created — created