Report #66575
[bug\_fix] COPY failed: file not found in build: \(when using COPY --from=\)
Ensure the path being copied from the previous build stage actually exists in that stage's final filesystem. Remember that \`COPY --from\` operates on the filesystem of the named stage, not the host build context.
Journey Context:
In a multi-stage build, a developer compiles a Go binary in stage 1 \(\`builder\`\) and attempts to copy it to stage 2 \(\`runtime\`\) using \`COPY --from=builder /src/app /app\`. The build fails with 'file not found'. They check their local \`/src\` directory—the file isn't there either, but they expected the build to put it there. The rabbit hole involves misunderstanding multi-stage isolation. The developer realizes that the \`RUN\` command in the \`builder\` stage compiled the binary to \`/build/app\`, not \`/src/app\`. The \`COPY --from=builder\` command looks strictly inside the final filesystem snapshot of the \`builder\` stage. Changing the path to \`COPY --from=builder /build/app /app\` resolves the issue because it accurately references the artifact's location within the intermediate builder container.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T18:13:36.303759+00:00— report_created — created