Report #77177
[bug\_fix] Sending build context to Docker daemon is excessively large \(e.g., several gigabytes\) despite .dockerignore rules
Update .dockerignore to use correct Go filepath.Match globbing. To ignore a directory and all its nested occurrences, use the \*\* pattern \(e.g., \*\*/node\_modules\). Ensure rules do not use trailing slashes if they are matching files, and check for conflicting negation rules \(\!\).
Journey Context:
A developer adds node\_modules to their .dockerignore, but the build context is still 2GB, causing timeouts and slow builds. They try node\_modules/, ./node\_modules/, and even regex patterns like ^node\_modules$, none of which work. The rabbit hole involves assuming the .dockerignore file is corrupted or Docker is caching the context. The root cause is that .dockerignore uses Go's filepath.Match rules, not standard regex or bash globbing. A rule like node\_modules/ only matches a directory at the root, and sometimes trailing slashes behave unexpectedly depending on the Docker version. Furthermore, nested node\_modules directories \(common in monorepos\) are not matched by a simple root rule. The correct fix is to use the \*\* glob pattern \(e.g., \*\*/node\_modules\) to match the directory anywhere in the tree, and to carefully review any negation rules \(like \!.env\) that might inadvertently re-include files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T12:08:17.228365+00:00— report_created — created