🚫 Don’t Send node_modules to Docker Daemon
Docker sends entire folder to daemon. .dockerignore excludes unnecessary files. Faster builds, smaller context.
📝 .dockerignore Example
# Git .git/ .gitignore # Node.js node_modules/ npm-debug.log package-lock.json # .NET bin/ obj/ *.user *.suo # Tests test/ __tests__/ coverage/ # Logs *.log logs/ # Environment .env .env.local .env.*.local # IDE .vscode/ .idea/ *.sln *.csproj.user # OS .DS_Store Thumbs.db # Build artifacts dist/ build/ out/
✅ Benefits
- Faster builds (less data to send)
- Smaller images (excluded files don’t end up in layers)
- Security (exclude .env, secrets, .git history)
- Cleaner (no IDE files, no temp files in image)
“Build context was 500MB (node_modules!). Added .dockerignore → 50MB. Build time dropped 80%. Always use .dockerignore.”
