Report #104495
[bug\_fix] COPY ../ outside build context: 'Forbidden path outside the build context'
Do not use '../' in COPY instructions. Instead, set the build context to a parent directory that includes all needed files, or restructure the project so that files to be copied are within the context directory. Use .dockerignore to exclude unwanted files.
Journey Context:
A developer tried to COPY a shared library from a sibling directory using 'COPY ../lib /app/lib' in the Dockerfile. They received 'COPY failed: forbidden path outside the build context'. The build context was the current directory '.' where the Dockerfile resided. The developer assumed that COPY could access any path on the host, but Docker strictly limits COPY to files within the build context. They then tried to work around by using 'docker build -f ../Dockerfile' but the context was still the directory containing the Dockerfile. The fix was to change the build context to the parent directory: 'docker build -f subdir/Dockerfile ..' which includes both the Dockerfile and the sibling directory. The developer updated their CI script to set the context to the project root. They also added a .dockerignore to exclude unnecessary files from the larger context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-30T20:02:48.028546+00:00— report_created — created