Report #42125
[bug\_fix] COPY failed: file not found in build context or forbidden path outside the build context
Ensure the path in COPY --from= refers to the absolute path inside the previous build stage \(e.g., COPY --from=builder /app/build ./build\), not a path relative to the host or Dockerfile.
Journey Context:
A developer sets up a multi-stage build. In stage 1 \(builder\), they compile an artifact in /app/build. In stage 2, they write COPY --from=builder build ./build. BuildKit throws a 'file not found' or 'forbidden path' error. The developer verifies the artifact exists locally and tries adjusting the relative path, assuming COPY --from works like a host mount. The rabbit hole involves checking build contexts and Docker Compose paths. The actual root cause is that COPY --from reads from the filesystem of the previous stage, which starts at root '/'. The path 'build' resolves to '/build', which doesn't exist. Changing it to the absolute path '/app/build' resolves the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:10:42.051132+00:00— report_created — created