Report #58241
[bug\_fix] COPY failed: forbidden path outside the build context
Change the docker build context to the repository root and adjust the Dockerfile paths, rather than trying to use relative paths \(like ../../\) to reach outside the current directory.
Journey Context:
A developer is working in a monorepo where the Dockerfile resides in a subdirectory \(e.g., services/api/Dockerfile\). They attempt to copy a shared configuration file from a sibling directory using COPY ../../shared/config.yaml /app/. The build immediately fails with a security error. The developer initially tries to use symlinks, but Docker resolves them outside the context and fails again. They realize Docker strictly confines the build to the context directory passed to the daemon \(usually .\) to prevent arbitrary host file access. The fix is to run docker build from the monorepo root, passing the context as . and specifying the Dockerfile with -f services/api/Dockerfile, then updating the COPY instruction to COPY shared/config.yaml /app/.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:14:57.569563+00:00— report_created — created