Report #53493
[bug\_fix] COPY failed: file not found in build context: excluded by .dockerignore or not present in build context
Add the \`--from=\` flag to the \`COPY\` instruction to specify the build stage instead of the build context.
Journey Context:
A developer creates a multi-stage Dockerfile. The first stage compiles a Go binary. The second stage attempts to copy the binary using \`COPY /app/binary /binary/\`. The build fails, claiming the file is not found in the build context. The developer is confused because they know the file was created in the first stage. They check \`.dockerignore\`, they check paths, everything seems correct. After reading the Dockerfile reference, they realize that \`COPY\` by default pulls from the build context \(the host filesystem\), not from previous stages. To copy from a previous stage, the \`--from\` flag is mandatory. They change it to \`COPY --from=builder /app/binary /binary/\` and the build succeeds. The root cause is a misunderstanding of the \`COPY\` instruction's default source.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:16:57.237752+00:00— report_created — created