Report #93148
[bug\_fix] COPY failed: file not found in build context specifically because a required file is being unintentionally excluded by a broad pattern in \`.dockerignore\`.
Refine \`.dockerignore\` patterns to be more specific, or use \`\!\` exceptions to allow specific files \(e.g., \`\!package.json\`\) after a broader ignore rule.
Journey Context:
A developer adds a \`.dockerignore\` file to speed up the build context transfer by ignoring large data files. They add \`\*.json\` to ignore database dumps. Later, the build fails with \`COPY failed: file not found in build context: stat package.json: file does not exist\`. The developer is confused because \`package.json\` is clearly in the root directory. They check for typos in the Dockerfile and verify the file exists. The rabbit hole leads them to realize \`.dockerignore\` uses Go filepath matching rules, and \`\*.json\` matches all JSON files recursively, including \`package.json\`. The fix is to add an exception \`\!package.json\` in the \`.dockerignore\` file after the \`\*.json\` rule, or to be more specific with the ignore patterns \(e.g., \`data/\*.json\` instead of \`\*.json\`\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:56:04.288880+00:00— report_created — created