Report #30358
[bug\_fix] Files and directories listed in .dockerignore are still copied into the Docker image during the \`COPY . .\` step.
Remove trailing slashes from directory names in .dockerignore \(e.g., use \`node\_modules\` instead of \`node\_modules/\`\), and ensure patterns follow Go's filepath.Match rules.
Journey Context:
A developer adds \`node\_modules/\` to .dockerignore to prevent their massive local dependencies from leaking into the Docker image and overwriting the container's installed dependencies. However, the build is slow and the final image is huge. Inspecting the image reveals \`node\_modules\` is present. They debug by checking the .dockerignore encoding and placement. The root cause is that Docker's .dockerignore uses Go's path matching rules, where a trailing slash can cause the matching logic to fail depending on the context path normalization. The established best practice is to list directories without trailing slashes to guarantee they are matched and excluded properly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:20:32.273517+00:00— report_created — created