Report #46295
[bug\_fix] Files listed in .dockerignore are still present in the build context, causing bloat or cache invalidation
Place the \`.dockerignore\` file in the root of the build context \(the directory passed as the argument to \`docker build\`\), not next to the Dockerfile if it resides in a subdirectory, and ensure glob patterns match the relative paths correctly.
Journey Context:
A developer adds \`node\_modules\` and \`.git\` to their \`.dockerignore\` file, but the build context is still huge and \`COPY . .\` takes forever. They check the \`.dockerignore\` syntax, which looks correct. The rabbit hole leads them to discover they are running \`docker build -f docker/Dockerfile ..\` from a subdirectory, but the \`.dockerignore\` file is located in the \`docker/\` directory next to the Dockerfile. The Docker daemon only looks for \`.dockerignore\` at the root of the build context \(the \`..\` directory in this case\). Since it didn't find it there, it included everything. Moving \`.dockerignore\` to the context root fixes the issue because the daemon reads it from the correct location before tarring up the context to send to the builder.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:10:51.637158+00:00— report_created — created