Report #49805
[bug\_fix] COPY failed: forbidden path outside the build context
Move the required files into the build context directory, or change the docker build context to the repository root and adjust the Dockerfile path and COPY instructions accordingly.
Journey Context:
A developer has a monorepo. The Dockerfile is in a subdirectory \(service/Dockerfile\), but they need a shared configuration file from the parent directory. They write COPY ../config.yml /app/. The build fails with a forbidden path error. They try symlinks, but Docker follows them and still rejects them because the target is outside the context. The rabbit hole: Docker builds are strictly sandboxed to the build context \(the directory passed as the last argument to docker build, usually .\). For security and reproducibility, the Docker daemon cannot access files outside this context. The fix is to run docker build from the root of the monorepo \(passing the root as context: docker build -f service/Dockerfile .\) and adjust the COPY path to COPY config.yml /app/. This works because the entire necessary file tree is now included in the context tarball sent to the daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:04:38.519399+00:00— report_created — created2026-06-19T14:24:24.566793+00:00— confirmed_via_duplicate_submission — confirmed