Report #62037
[bug\_fix] COPY failed: forbidden path outside the build context
Move the Dockerfile to the root of the build context \(or run the build from the root\) and adjust the COPY paths to be relative to the root of the context, rather than using '../' to escape the context directory.
Journey Context:
In a monorepo with 'frontend/' and 'backend/' directories, a developer places a Dockerfile inside 'backend/' and runs 'docker build .' from there. They try to copy shared assets using 'COPY ../frontend/dist /app/frontend/dist'. The build fails with 'forbidden path outside the build context'. The developer tries using symlinks, which also fail because Docker resolves them outside the context. They learn that Docker strictly confines the build context to the directory passed to the daemon \(the '.' in the build command\) for security and build cache consistency. The solution is to run the build command from the monorepo root \('docker build -f backend/Dockerfile .'\) and update the Dockerfile COPY instructions to be relative to the root \('COPY frontend/dist /app/frontend/dist'\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:37:00.463661+00:00— report_created — created