Report #9750
[bug\_fix] .dockerignore fails to ignore directories correctly, causing massive build context
Use the correct syntax in \`.dockerignore\`. Remember that a leading slash \`/\` anchors to the build context root. To ignore a directory anywhere, use \`\*\*/node\_modules\`. To ignore only the root one, use \`/node\_modules\`. Avoid trailing slashes.
Journey Context:
A developer notices their \`docker build\` context is 1GB instead of 10MB. They add \`node\_modules/\` to \`.dockerignore\`, but it doesn't work. They try \`./node\_modules\` and \`\*\*/node\_modules\`. The build is still slow. They finally realize they had a trailing slash in their ignore file \(\`node\_modules/\`\), which \`.dockerignore\` handles differently than \`.gitignore\`, or they placed the \`.dockerignore\` file in the wrong directory \(it must be at the root of the build context\). Removing the trailing slash or moving the file to the context root fixes it. The fix works because \`.dockerignore\` matching rules differ slightly from \`.gitignore\` \(specifically regarding trailing slashes and directory vs file matching\) and the file must reside at the context root to be parsed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:54:22.598990+00:00— report_created — created