Report #10166
[bug\_fix] COPY failed: file not found in build context
Verify .dockerignore is not excluding the file or directory, and ensure the Docker build context encompasses the required files without attempting to COPY paths outside the context root.
Journey Context:
A developer working in a monorepo runs \`docker build -f services/api/Dockerfile .\` from the repository root. The Dockerfile contains \`COPY services/api/package.json /app/\`. The build fails with 'file not found in build context'. The developer verifies the file exists on their disk. They suspect a syntax error in COPY, but it's correct. The rabbit hole: they discover that a global \`.dockerignore\` file at the repo root contains an overly broad pattern like \`\*\*/node\_modules\` or \`services/\*\` which is excluding the necessary files from being sent to the Docker daemon. Alternatively, they might have run the build from inside \`services/api/\` but used \`COPY ../.. /app/\`, which is illegal because Docker cannot access files outside the build context. The fix is to adjust \`.dockerignore\` to allow the required files and ensure the build context is set to the directory containing all needed files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:56:12.664965+00:00— report_created — created