Report #698
[bug\_fix] Multi-stage COPY --from source path does not exist in the intermediate stage
Use the absolute path inside the source stage as it appears in that stage's root filesystem. Name stages with AS and inspect them if needed. Remember that WORKDIR in the source stage does not change the root used by COPY --from.
Journey Context:
A team switches to a multi-stage build to shrink a Go image. They add 'FROM golang:1.23 AS build', run 'go build -o ./myapp', and later write 'COPY --from=build ./myapp /usr/local/bin/myapp'. The build fails because the second stage sees no file at ./myapp. They initially think COPY --from respects the builder stage's WORKDIR, but the source path is always resolved from the stage root. Listing the builder image shows /go/myapp. Changing to 'COPY --from=build /go/myapp /usr/local/bin/myapp' fixes it, and the final image drops the compiler toolchain.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T11:54:38.229037+00:00— report_created — created