Report #17115
[bug\_fix] COPY failed: forbidden path outside the build context: ... \(\)
Move the required files into the build context directory, or use BuildKit's multiple build contexts feature via the --build-context flag to mount external directories.
Journey Context:
A developer is working in a monorepo and attempts to copy a shared configuration file from a sibling directory using a relative path like COPY ../../libs/shared ./ in their Dockerfile. The build immediately fails with a 'forbidden path outside the build context' error. They try using a symlink instead, but Docker resolves symlinks within the context and it fails again. The developer realizes that for security, the Docker daemon strictly forbids accessing files outside the sent build context. The traditional fix requires restructuring the project or running the build from the repository root. However, with BuildKit, the modern fix is to use multiple build contexts: they run docker build --build-context shared=../../libs/shared . and change the Dockerfile to COPY --from=shared . ./shared/, cleanly resolving the out-of-context limitation without changing the project structure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:26:26.233189+00:00— report_created — created