Report #65957
[bug\_fix] COPY failed: file not found in build context: required by \[stage-name\]
Ensure the source path in the COPY instruction is relative to the build context root \(usually the repository root\), not the location of the Dockerfile, and verify the file is not excluded by \`.dockerignore\`.
Journey Context:
In a monorepo setup, a developer places a Dockerfile inside a subdirectory \(\`services/api/Dockerfile\`\). They run \`docker build -f services/api/Dockerfile .\` from the repository root. The Dockerfile contains \`COPY package.json .\`, but the build fails claiming the file is not found. The developer verifies the file exists right next to the Dockerfile. They go down a rabbit hole checking file permissions and symlinks before realizing that Docker always evaluates COPY paths relative to the build context \(the \`.\` at the end of the build command\), not the Dockerfile location. The fix is to change the instruction to \`COPY services/api/package.json .\` to match the context root, or change the build context to the subdirectory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:11:22.786894+00:00— report_created — created