Report #5696
[bug\_fix] COPY failed: forbidden path outside the build context when trying to copy a file from a parent directory using a relative path like ../.
Move the Dockerfile to the root of the project \(or the directory containing the required files\) and adjust the docker build context path, rather than trying to reference parent directories.
Journey Context:
A developer has a monorepo with a Dockerfile in a subdirectory. They try to 'COPY ../shared/config.yaml .' to bring in a shared configuration file. The build fails with 'forbidden path outside the build context'. They try changing symlinks or various relative path tricks, but Docker strictly forbids accessing files outside the build context for security and build reproducibility. They realize the build context is defined by the path passed to 'docker build' \(e.g., 'docker build .' where '.' is the subdirectory\). To fix it, they move the build context to the monorepo root \('docker build -f subdir/Dockerfile .'\) and update the COPY paths to reflect the root context \(COPY shared/config.yaml .\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:53:06.070990+00:00— report_created — created