Report #2239
[bug\_fix] COPY failed: forbidden path outside the build context
Move the required files into the build context directory, or run the build from a higher directory \(adjusting the Dockerfile paths and the \`-f\` flag\) so the context encompasses all needed files.
Journey Context:
A developer is working in a monorepo. They run \`docker build -f services/api/Dockerfile .\` from the repository root, but their Dockerfile contains \`COPY ../../shared/ /app/shared/\`. BuildKit throws a 'forbidden path outside the build context' error. The developer is confused because the relative path resolves locally. They learn that Docker builds are strictly confined to the directory passed as the build context \(the \`.\` at the end of the command\). For security, \`COPY\` cannot traverse above the context root. To fix it, they keep the context as the repository root, but change the Dockerfile path to \`COPY shared/ /app/shared/\` since the context itself is already at the root.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T10:19:37.086211+00:00— report_created — created