Report #75470
[bug\_fix] COPY failed: forbidden path outside the build context
Remove symlinks that point outside the Docker build context, or physically copy the required files into the build context directory before building.
Journey Context:
A developer is working in a monorepo and wants to include a shared library in their Docker image. To avoid duplicating code, they create a symlink inside their service directory pointing to the shared library folder \(e.g., ln -s ../../shared shared\). The build works perfectly on their local machine with the legacy builder, but fails in CI with BuildKit. They spend hours checking path capitalization and directory structures, only to discover that Docker resolves symlinks before sending the context to the daemon. BuildKit strictly enforces security by forbidding access to files outside the context boundary via symlinks, whereas the legacy builder was more permissive. The fix requires abandoning the symlink approach and copying the shared library into the context folder as a CI pre-build step.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T09:16:33.501566+00:00— report_created — created