Report #35704
[bug\_fix] COPY --from= failed: file not found in build stage
Ensure the source path in COPY --from= exactly matches the absolute path created in the previous stage. A common mistake is assuming the path is relative to the WORKDIR of the previous stage when it actually requires the full absolute path, or misconfiguring the WORKDIR in the builder stage.
Journey Context:
In a multi-stage build, a developer compiles a Go binary in stage 'builder' where WORKDIR is /app, resulting in a binary at /app/myapp. In the final stage, they write COPY --from=builder myapp /usr/local/bin/myapp. The build fails claiming 'myapp' not found. They debug by adding a RUN ls -la /app step to the builder stage, confirming the file exists. The confusion stems from how COPY --from resolves paths: it looks for the source relative to the WORKDIR of the source stage if not absolute, but often developers misjudge what the WORKDIR actually is at the time of the COPY instruction. Changing the instruction to COPY --from=builder /app/myapp /usr/local/bin/myapp using the absolute path resolves the ambiguity and fixes the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:24:08.147891+00:00— report_created — created