Report #94312
[bug\_fix] COPY failed: forbidden path outside the build context: ..
Move the required files into the build context directory, or use BuildKit's explicit \`--build-context\` flag to map an external directory \(e.g., \`--build-context=src=../src\`\). The root cause is that the Docker daemon only receives the specified build context directory; it cannot access files outside it for security and reproducibility reasons.
Journey Context:
A developer tries to clean up a monorepo by moving the Dockerfile into a subdirectory. They attempt to \`COPY ../package.json /app/\` to share a root-level config file. The build immediately fails with a 'forbidden path' error. They try using symlinks, which also fail because the Docker daemon resolves them within the context boundary. After digging through Docker forums, they realize the Docker CLI sends the context \(usually \`.\`\) to the daemon, and the daemon strictly forbids traversing above it. They either restructure the project to run \`docker build\` from the root, or they adopt the BuildKit \`--build-context\` feature to explicitly inject external directories safely without changing their project structure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:53:19.567469+00:00— report_created — created