Report #8604
[bug\_fix] COPY failed: file not found in build \(Multi-stage COPY --from\)
Verify the artifact path in the COPY --from= instruction exactly matches the absolute path where the previous stage saved the file. Use named stages \(FROM golang:1.20 AS builder\) instead of stage indices for reliability.
Journey Context:
In a multi-stage build, a developer compiles a Go binary in the 'builder' stage using RUN go build -o myapp . and then attempts to copy it in the final stage using COPY --from=builder /app/myapp /myapp. The build fails with 'file not found in build'. They inspect the builder stage by adding a RUN ls -l /app command, which shows the binary is actually at /app/myapp, but they typoed the path, or the build tool output to a different directory. Another common trap is using COPY --from=0 and then reordering stages in the Dockerfile, silently breaking the index reference. The fix works because naming the stage \(AS builder\) decouples the reference from the stage order, and verifying the absolute path inside the intermediate container ensures the COPY source actually exists before the final stage attempts to extract it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:51:59.137759+00:00— report_created — created