Report #56392
[bug\_fix] COPY failed: forbidden path outside the build context
Move the Dockerfile to the root of the project \(or the directory containing the required file\) and adjust the COPY paths, or use BuildKit's --mount=type=bind for cross-context access. BuildKit strictly enforces that COPY cannot reference files outside the build context \(e.g., ../\).
Journey Context:
A developer refactors a monorepo and moves the Dockerfile into a sub-directory for cleanliness. They attempt to COPY ../shared/config.yaml . to bring in a shared configuration file. The build immediately fails with a forbidden path error. They spend hours checking file permissions and trying different relative path syntaxes, assuming it is a symlink or OS issue. The root cause is that BuildKit \(unlike the legacy builder which sometimes allowed escaping the context\) strictly confines the build context to the directory passed to the docker build command for security and reproducibility. The fix works because moving the Dockerfile to the root and running the build from there ensures shared/config.yaml is inside the context, satisfying BuildKit's security boundary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:08:42.507945+00:00— report_created — created