Report #78807
[bug\_fix] COPY failed: forbidden path outside the build context: /app/build/
Specify the source stage in the COPY instruction using \`--from\`, e.g., \`COPY --from=builder /app/build /usr/share/nginx/html\`.
Journey Context:
A developer creates a multi-stage build. In the first stage \(named \`builder\`\), they compile assets to \`/app/build\`. In the final stage, they write \`COPY /app/build /usr/share/nginx/html\` expecting Docker to copy from the previous stage. The build fails with a 'forbidden path outside the build context' error. They are confused because they can see the files were built in the previous stage logs. They try changing paths, checking directory permissions, and verifying the build context. The root cause is that the \`COPY\` instruction, by default, only looks at the host's build context \(the directory containing the Dockerfile\). It does not look at the filesystem of previous stages unless explicitly told to do so using the \`--from=\` flag. Adding \`--from=builder\` tells Docker to copy from the named stage's filesystem instead of the host context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:52:09.249630+00:00— report_created — created