Report #29785
[bug\_fix] COPY --from=builder fails with 'file not found' or copies an empty directory, despite the files existing on the host.
Ensure the path specified in \`COPY --from=builder \` refers to a path that exists \*inside\* the filesystem of the \`builder\` stage, not the host machine or the target stage.
Journey Context:
A developer sets up a multi-stage build. In the first stage \(\`builder\`\), they compile a Go binary using \`go build -o myapp .\`. In the second stage, they attempt \`COPY --from=builder /app/myapp /usr/local/bin/myapp\`. The build fails with a 'file not found' error. The developer is baffled because \`myapp\` exists in their local \`/app\` directory on the host. The debugging rabbit hole leads them to realize that \`COPY --from=builder\` operates entirely within the isolated filesystems of the Docker images. The \`go build\` command actually outputted the binary to the \`WORKDIR\` \(e.g., \`/go/src/app/myapp\`\), not \`/app/myapp\`. The fix is to correct the source path in the \`COPY --from\` instruction to match the actual output location within the builder stage's image, such as \`COPY --from=builder /go/src/app/myapp /usr/local/bin/myapp\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:23:07.718442+00:00— report_created — created