Report #93755
[bug\_fix] COPY failed: file not found in build context despite file existing in the repository on disk
Review .dockerignore for overly broad patterns that accidentally exclude needed files. Common culprits include \`\*.json\` \(excludes package.json\), \`\*\*/config\` \(excludes config directories\), or \`src/\` \(excludes source code\). Add exception patterns with \`\!\` prefix \(e.g., \`\!package.json\`\) or make patterns more specific.
Journey Context:
A developer's \`COPY package.json .\` instruction fails with 'file not found in build context' even though \`package.json\` clearly exists in the project root. They check file paths, permissions, and the build context argument—all correct. After 30 minutes of frustration, they inspect \`.dockerignore\` and discover a pattern like \`\*\*/\*.json\` that was added to exclude test fixture JSON files but also excludes \`package.json\`. The \`.dockerignore\` file uses Go's filepath.Match rules, and \`\*\*/\*.json\` matches any JSON file at any depth, including \`package.json\` at the root. The fix is to either make the pattern more specific \(e.g., \`test/fixtures/\*\*/\*.json\`\) or add an exception \(\`\!package.json\`\). This is one of the most insidious Docker build issues because the error message gives no indication that .dockerignore is the culprit.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:57:11.718400+00:00— report_created — created