Optimize Docker builds with comprehensive .dockerignore templates for 87+ technologies
Why
.dockerignorematters: Docker sends your entire build context to the daemon. A.dockerignorefile excludes unnecessary files, making builds faster, more secure, and more efficient.
# React project
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/frameworks/react.dockerignore
# Django project
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/frameworks/django.dockerignore
# Node.js project
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/languages/nodejs.dockerignoredockerignore.com - Browse templates and generate custom .dockerignore files.
| Benefit | Impact | Example |
|---|---|---|
| Faster Builds | 50-90% reduction in context size | 500MB → 50MB |
| Enhanced Security | Sensitive files never reach Docker | .env, credentials, keys |
| Better Caching | Cache layers stay valid longer | node_modules/ changes don't invalidate cache |
| Smaller Images | Unnecessary files excluded | Development tools, test files |
| Improved CI/CD | Faster pipeline execution | Quicker deployments |
# Without .dockerignore
$ docker build --no-cache .
Sending build context to Docker daemon 512.3MB
# With .dockerignore
$ docker build --no-cache .
Sending build context to Docker daemon 45.2MB # 91% reduction!Self-contained, security-first templates for specific frameworks
- Location:
frameworks/ - Examples:
react.dockerignore,django.dockerignore,spring-boot.dockerignore - Usage: Use standalone - includes security patterns first
Language-specific patterns for modular combination
- Location:
languages/ - Examples:
nodejs.dockerignore,python.dockerignore,java.dockerignore - Usage: Combine with common templates
Cross-cutting concerns for all projects
- Location:
common/ - Examples:
security.dockerignore,cache.dockerignore,logs.dockerignore - Usage: Combine with language templates
Build and deployment tool patterns
- Location:
tools/ - Examples:
vite.dockerignore,webpack.dockerignore,vercel.dockerignore
Editor and IDE configuration files
- Location:
ides/ - Examples:
visual-studio-code.dockerignore,intellij.dockerignore
Operating system-specific files
- Location:
os/ - Examples:
linux.dockerignore,macos.dockerignore,windows.dockerignore
# Single framework template (self-contained)
cp frameworks/react.dockerignore .dockerignore# Combine language with common templates
cat languages/python.dockerignore \
common/security.dockerignore \
common/cache.dockerignore > .dockerignore# Example: Python web project
cat languages/python.dockerignore \
common/security.dockerignore \
common/cache.dockerignore \
common/logs.dockerignore \
tools/docker.dockerignore > .dockerignore# Always include security patterns in your .dockerignore
cat common/security.dockerignore >> .dockerignore# Test what files are being excluded
docker build --no-cache . 2>&1 | grep -i "sending\|context"# Remove duplicate patterns when combining templates
cat template1 template2 | sort -u > .dockerignore- Review your
.dockerignorefile quarterly - Update when adding new tools or dependencies
- Remove patterns for tools you no longer use
Framework templates are self-contained and include:
- Security patterns first
- Language-specific patterns
- Framework-specific patterns
- Build and cache directories
A: Use framework templates for framework-based projects (React, Django, etc.). Use language templates for custom projects or when no framework template exists.
A: Use cat to combine templates and sort -u to remove duplicates:
cat languages/python.dockerignore \
common/security.dockerignore \
common/cache.dockerignore | sort -u > .dockerignoreA: Add the specific pattern to your .dockerignore file:
# Add to .dockerignore
my-specific-file.txt
config/local.jsonA: Use Docker build with verbose output:
docker build --no-cache . 2>&1 | grep -i "sending\|context"A: Yes! .dockerignore works with both docker build and docker-compose build.
All templates follow strict standards defined in TEMPLATE_STANDARDS.md:
- Security-first approach - Framework templates include security patterns first
- Consistent structure - Standardized headers and organization
- Alphabetical sorting - Patterns sorted within sections
- Clear documentation - Usage notes and combination guidance
- No duplicates - Each pattern appears only once
We welcome contributions! Please see CONTRIBUTING.md for guidelines on:
- Creating new templates
- Improving existing templates
- Reporting issues
- Submitting pull requests
- TEMPLATE_STANDARDS.md - Definitive template standards
- CONTRIBUTING.md - Contributor guidelines
- AGENTS.md - Maintainer handbook
This project is licensed under the MIT License - see the LICENSE file for details.
Visit dockerignore.com for:
- Interactive template browser
- Custom
.dockerignoregenerator - Documentation and examples
- Community resources
If you find this project helpful, please:
- Star the repository on GitHub
- Share with your team and community
- Contribute templates or improvements
- Report issues or suggest features
Optimize your Docker builds today with comprehensive .dockerignore templates!