Report #491
[bug\_fix] COPY fails with 'file not found in build context' or 'failed to compute cache key: .../foo.txt: not found' even though the file exists next to the Dockerfile
Check .dockerignore at the root of the build context. If the file or its directory is excluded, narrow or remove the ignore pattern so the file is included in the context, then rebuild.
Journey Context:
A teammate added a broad .dockerignore rule \(\*\*/config/\*\) to keep secrets out of images. Months later COPY config/base.yaml /app/config/ failed in CI with 'file not found'. The file was in Git and present locally, but the build log showed the context being filtered before BuildKit ever saw it. BuildKit resolves COPY paths only against the filtered context sent to the builder, so an over-eager .dockerignore silently removes the file. We narrowed the rule to config/\*.local.yaml and the COPY succeeded on the next build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T08:55:26.155526+00:00— report_created — created