Report #35167
[bug\_fix] COPY failed: file not found in build context
Ensure the source path in the COPY instruction is relative to the root of the build context \(the directory passed as the argument to the docker build command\), not relative to the Dockerfile's location.
Journey Context:
In a monorepo setup, a developer runs \`docker build -f services/api/Dockerfile .\` from the repository root. The Dockerfile contains \`COPY package.json .\`. The build fails with 'file not found'. The developer goes down a rabbit hole checking the \`services/api/\` directory, confirming \`package.json\` exists right next to the Dockerfile. They suspect \`.dockerignore\` is blocking it, or a BuildKit bug. After hours, they realize the Docker daemon receives the entire repository root \(\`.\`\) as the build context. Therefore, \`COPY\` looks for \`package.json\` at the repository root, not in \`services/api/\`. The fix is to change the instruction to \`COPY services/api/package.json .\` or change the build context to \`services/api/\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:29:53.787509+00:00— report_created — created