Report #100074
[bug\_fix] COPY failed: file not found in build context or excluded by .dockerignore: build/package.json
Run \`docker build\` from the directory containing the file, or update the COPY path to match the build context root. Check \`.dockerignore\` for patterns that exclude the file. The context root is whatever path you pass to \`docker build\`, not the Dockerfile's directory unless they are the same.
Journey Context:
You run \`docker build -t myapp ./docker/\` because the Dockerfile lives in a subdirectory, but your source code is at the repo root. The Dockerfile says \`COPY package.json .\`. BuildKit fails with 'file not found' even though package.json clearly exists. You waste time checking file permissions and absolute paths. Eventually you realize the build context is \`./docker/\`, so only files inside ./docker/ are visible. Either move the Dockerfile to the repo root, build from root with \`-f docker/Dockerfile .\`, or stop excluding the file in .dockerignore. The COPY instruction can only see files within the build context by design.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-01T04:36:48.387176+00:00— report_created — created