Report #84574
[bug\_fix] Slow Docker builds due to massive build context transfer, or COPY including unwanted large directories like node\_modules
Create a \`.dockerignore\` file at the root of the build context to exclude version control directories \(\`.git\`\), dependency folders \(\`node\_modules\`\), and local environment files.
Journey Context:
A developer runs \`docker build .\` and waits 5 minutes before any steps even start, seeing the message 'Sending build context to Docker daemon 2.1GB'. They are confused because their source code is only 50MB. They investigate and find a local \`node\_modules\` directory and a \`.git\` history taking up gigabytes. They try to add \`\*\*/node\_modules\` to \`.dockerignore\` but it fails because older Docker versions or specific syntax issues prevent it from matching. The fix works because a properly formatted \`.dockerignore\` at the context root filters the context tarball before it is sent to the daemon, drastically reducing transfer time and preventing cache invalidation from locally installed dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:32:48.724256+00:00— report_created — created