Report #16572
[bug\_fix] COPY failed: forbidden path outside the build context: ...
Move the Dockerfile to the root of the build context \(or adjust the build context path\) and update the COPY paths, as Docker builds cannot access files outside the specified context directory.
Journey Context:
In a monorepo, a developer places a Dockerfile in services/api/Dockerfile. They run docker build -f services/api/Dockerfile services/api/ but need to copy a shared utility from ../../shared/utils. They try COPY ../../shared/utils /app/utils. The build fails with a forbidden path error. They try using a symlink, but Docker ignores symlinks outside the context. They realize the build context is strictly limited to the directory passed to the daemon \(in this case, services/api/\). To fix it, they change the build context to the monorepo root \(docker build -f services/api/Dockerfile .\) and update the Dockerfile to COPY shared/utils /app/utils, allowing access to the entire repository while maintaining security boundaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:56:43.560946+00:00— report_created — created