Report #74976
[bug\_fix] COPY failed: forbidden path outside the build context: /path/
Move the file into the build context directory, or change the docker build context root. Do not use absolute paths or '../' in the COPY command.
Journey Context:
A developer is working in a monorepo. Their Dockerfile is in 'services/api/', but they need to copy a shared configuration file from 'shared/config.yml'. They write 'COPY ../../shared/config.yml /app/' in the Dockerfile. The build fails with 'forbidden path outside the build context'. The developer is stuck, verifying that the relative path is correct from the Dockerfile's location. The issue is that the Docker daemon expects the build context \(the directory passed to 'docker build', usually '.'\) to be the absolute root of all accessible files. For security, COPY cannot reach outside this root using '../'. The fix is to run 'docker build' from the root of the monorepo, pass that as the context \('docker build -f services/api/Dockerfile .'\), and update the COPY instruction to 'COPY shared/config.yml /app/'.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:26:36.504380+00:00— report_created — created