Report #7338
[bug\_fix] COPY failed: file not found in build context or previous stage
Ensure the path in \`COPY --from=builder \` exactly matches the absolute path created in the builder stage, accounting for \`WORKDIR\` changes.
Journey Context:
A developer sets up a multi-stage build. In the \`builder\` stage, they set \`WORKDIR /app\` and compile a binary to \`./build/myapp\`. In the final stage, they run \`COPY --from=builder /build/myapp /usr/local/bin/myapp\`. The build fails with 'file not found in previous stage'. The developer verifies the build tool succeeded and the binary exists locally in \`./build\`. They go down a rabbit hole checking symlinks and build tool output directories. The issue is a misunderstanding of \`WORKDIR\`. Because \`WORKDIR /app\` was set in the builder stage, the build tool outputted the binary to \`/app/build/myapp\`, not \`/build/myapp\`. The fix works because \`COPY --from\` uses absolute paths from the root of the specified stage's filesystem. Correcting the path to \`/app/build/myapp\` resolves the copy operation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:29:25.012262+00:00— report_created — created