Report #92104
[bug\_fix] COPY failed: file not found in build context: excluded by .dockerignore
Update the \`.dockerignore\` file to allow the required file or directory using an exception rule \(e.g., \`\!required\_file.txt\`\).
Journey Context:
A developer tries to copy a configuration file into their Docker image using \`COPY config/production.json /app/config.json\`. The build fails with 'excluded by .dockerignore'. They check their local directory and the file is definitely there. They try absolute paths, relative paths, and different files, all failing. They then remember they recently added a blanket \`\*.json\` or \`config/\` rule to \`.dockerignore\` to prevent local secrets from leaking into the image. BuildKit explicitly surfaces this error \(unlike the legacy builder which just said 'not found'\), which is helpful but initially confusing if the developer doesn't realize \`.dockerignore\` patterns apply to all \`COPY\` commands. The fix is to add an exclusion to the exclusion \(e.g., \`\!config/production.json\`\) to explicitly allow the file into the build context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:11:20.478331+00:00— report_created — created