Report #12999
[bug\_fix] COPY failed: forbidden path outside the build context when using symlinks
Remove symlinks that point outside the build context and copy actual files, or restructure the repository to run the build from a parent directory.
Journey Context:
A developer has a monorepo with shared libraries. To make them available to a specific service Docker build, they create a symlink service/shared -> ../../shared. The docker build fails with forbidden path outside the build context. They try changing permissions, using absolute symlinks, and modifying the Dockerfile. The build continuously fails. They discover that Docker resolves symlinks and strictly enforces that the target must reside within the build context. Because the symlink points outside the . context passed to the Docker daemon, it is rejected. The fix is to either run the build from the monorepo root \(changing the context and Dockerfile path\) or use a script to copy the shared files into the service directory before building. This works because it respects the security boundary of the Docker build context, preventing arbitrary host file access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:26:22.007055+00:00— report_created — created