Report #13161
[bug\_fix] COPY failed: file not found in build context or excluded by .dockerignore during a multi-stage build COPY --from=builder ...
Ensure the path being copied from the previous stage actually exists in that stage's filesystem, and verify that the source path in COPY --from matches the exact path created in the builder stage. Note that .dockerignore does not apply to inter-stage copies.
Journey Context:
A developer sets up a multi-stage build. Stage 1 \(builder\) compiles an app to /app/dist/main.js. Stage 2 uses COPY --from=builder /app/dist /app/dist. The build fails with 'file not found'. The developer assumes .dockerignore is the culprit and wastes time deleting .dockerignore rules, but the error persists. They eventually realize .dockerignore only applies to the initial build context sent from the client to the daemon, not to inter-stage copies. The real issue is that the build command in stage 1 failed silently or outputted to a different directory \(e.g., /app/build instead of /app/dist\). Fixing the path in the COPY --from to match the actual output of the builder stage resolves it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:54:26.938401+00:00— report_created — created