Production-Ready Dockerfile Templates for Modern Applications
A comprehensive collection of security-hardened, production-ready Dockerfile templates following industry best practices.
# Download a template directly
curl -o Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/frameworks/react.Dockerfile
# Or copy from this repository
cp frameworks/react.Dockerfile Dockerfile
# Build and run
docker build -t my-app .
docker run -p 3000:3000 my-app# Create custom Dockerfile by combining templates
cat languages/nodejs.Dockerfile \
patterns/multi-stage.Dockerfile \
patterns/security-hardened.Dockerfile > Dockerfile| Category | Templates | Description | Best For |
|---|---|---|---|
| ποΈ Framework Templates | 1 template | Complete, production-ready templates | Beginners, production deployments |
| π» Language Templates | 1 template | Language-specific patterns | Custom applications, modular setups |
| π‘οΈ Pattern Templates | 4 templates | Reusable patterns (security, multi-stage, etc.) | All projects, security hardening |
Total: 6 templates across 3 categories
- Non-root users by default in all framework templates
- Specific base image versions (no
latesttags) - Security-hardened configurations with proper permissions
- Health checks for container orchestration and monitoring
- Multi-stage builds for minimal image sizes
- Optimized layer caching for faster CI/CD pipelines
- Industry best practices from Docker and community experts
- Tested configurations that work in real production environments
- Combine templates like building blocks
- Framework templates for quick starts
- Language templates for custom applications
- Common patterns for cross-cutting concerns
Complete, self-contained templates for specific frameworks
- Location:
frameworks/ - Usage: Use standalone - includes everything needed
- Current Templates: React
- Best For: Beginners, quick starts, production deployments
Example:
cp frameworks/react.Dockerfile DockerfileLanguage-specific patterns designed for combination
- Location:
languages/ - Usage: Combine with pattern templates
- Current Templates: Node.js
- Best For: Custom applications, modular architecture
Example:
cat languages/nodejs.Dockerfile \
patterns/security-hardened.Dockerfile > DockerfileReusable patterns for all projects
- Location:
patterns/ - Usage: Combine with language or framework templates
- Current Templates: Multi-stage builds, Security hardening, Alpine Linux, Docker Compose
- Best For: Security hardening, performance optimization, OS-specific needs, tool integrations
Available Templates:
multi-stage.Dockerfile- Optimized build patternssecurity-hardened.Dockerfile- Production security configurationsalpine.Dockerfile- Alpine Linux optimizationsdocker-compose.Dockerfile- Docker Compose integration
# 1. Choose your framework template
cp frameworks/react.Dockerfile Dockerfile
# 2. Get matching .dockerignore (optional but recommended)
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/frameworks/react.dockerignore
# 3. Build your application
docker build -t my-app .
# 4. Run your container
docker run -p 3000:3000 my-app# 1. Create custom Dockerfile by combining templates
cat languages/nodejs.Dockerfile \
patterns/multi-stage.Dockerfile \
patterns/security-hardened.Dockerfile > Dockerfile
# 2. Review and customize
# Edit Dockerfile to match your application needs
# 3. Build with custom arguments
docker build \
--build-arg NODE_ENV=production \
--build-arg BUILD_ID=$(git rev-parse --short HEAD) \
-t my-app:$(git rev-parse --short HEAD) .
# 4. Run with environment variables
docker run -d \
-p 3000:3000 \
-e NODE_ENV=production \
--name my-app-container \
my-app:latest# Download any template directly from GitHub
curl -o Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/frameworks/react.Dockerfile
# Or use wget
wget -O Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/languages/nodejs.Dockerfile# Complete production setup for Node.js
cat languages/nodejs.Dockerfile \
patterns/multi-stage.Dockerfile \
patterns/security-hardened.Dockerfile > Dockerfile
# Build for production
docker build --target runtime -t my-node-app:prod .
# Run with resource limits
docker run -d \
-p 3000:3000 \
--memory="512m" \
--cpus="1.0" \
my-node-app:prod# React with Alpine Linux optimizations
cat frameworks/react.Dockerfile \
patterns/alpine.Dockerfile > Dockerfile
# Build and run
docker build -t my-react-app .
docker run -p 3000:3000 my-react-app# Development setup with hot reload
cat languages/nodejs.Dockerfile > Dockerfile
# Then edit Dockerfile to uncomment development configurations
# Build development image
docker build -t my-app:dev .
# Run with volume mounting for live reload
docker run -d \
-p 3000:3000 \
-v $(pwd):/app \
-v /app/node_modules \
my-app:dev- β Non-root user execution - Reduced attack surface
- β
Specific version pinning - No
latesttag vulnerabilities - β Minimal base images - Reduced CVE exposure
- β Proper file permissions - Principle of least privilege
- β Health checks - Automatic container monitoring
- β Resource limits - Prevention of resource exhaustion attacks
- β Multi-stage builds - Minimal final image sizes
- β Layer caching optimization - Faster build times
- β Alpine Linux support - Smaller image footprints
- β Build argument support - Flexible configuration
- β Environment variable management - Runtime customization
- β Clear documentation - Inline comments and examples
- β Modular design - Combine as needed
- β Production and development targets - Separate configurations
- β Best practice examples - Learn as you use
- β Community standards - Follows Docker best practices
- TEMPLATE_STANDARDS.md - Template creation and formatting standards
- CONTRIBUTING.md - How to contribute templates and improvements
- AGENTS.md - AI agent handbook for template maintenance
All templates follow strict standards documented in TEMPLATE_STANDARDS.md:
- Consistent header format with attribution
- Metadata section with usage notes and combination guidance
- Security-first approach in framework templates
- Clear section organization with visual separators
- Comprehensive documentation with practical examples
# 1. Get Dockerfile template
curl -o Dockerfile https://raw.githubusercontent.com/ronald2wing/Dockerfile/master/frameworks/react.Dockerfile
# 2. Get .dockerignore template (security and performance)
curl -o .dockerignore https://raw.githubusercontent.com/ronald2wing/.dockerignore/master/frameworks/react.dockerignore
# 3. Get .gitignore template (repository optimization)
curl -o .gitignore https://raw.githubusercontent.com/ronald2wing/.gitignores/master/frameworks/react.gitignore
# 4. Build and test
docker build -t my-app .
docker run --rm -p 3000:3000 my-app
# 5. Deploy to production
docker tag my-app my-registry/my-app:latest
docker push my-registry/my-app:latest# Quick test of any template
mkdir test-template && cd test-template
cp ../path/to/template.Dockerfile Dockerfile
# Create minimal test files
echo '{"name": "test", "version": "1.0.0"}' > package.json
echo 'console.log("Test successful")' > index.js
# Test build and run
docker build --no-cache -t template-test .
docker run --rm template-test
# Cleanup
docker rmi template-test
cd .. && rm -rf test-template- Always use specific versions of base images
- Run as non-root user in production
- Use multi-stage builds to exclude build tools
- Scan images regularly for vulnerabilities
- Set resource limits to prevent DoS attacks
- Use .dockerignore to exclude sensitive files
- Order instructions carefully for optimal layer caching
- Use Alpine or slim variants for smaller images
- Clean package caches in the same RUN instruction
- Use build arguments for environment-specific optimizations
- Consider multi-architecture builds for broader deployment
- Update base images quarterly for security patches
- Review templates annually for new best practices
- Test with new Docker versions for compatibility
- Document changes clearly for users and contributors
- Engage with community for feedback and improvements
We welcome contributions! Whether you're adding new templates, improving existing ones, or fixing bugs, your help is appreciated.
See CONTRIBUTING.md for detailed guidelines.
- Add new templates for popular technologies
- Improve existing templates with new best practices
- Fix bugs or security issues in current templates
- Improve documentation and examples
- Add test cases for template validation
# 1. Fork and clone the repository
git clone https://github.com/your-username/Dockerfile.git
cd Dockerfile
# 2. Create a new template following TEMPLATE_STANDARDS.md
# 3. Test your template thoroughly
# 4. Submit a pull request- .dockerignore Templates - 87+ .dockerignore templates
- .gitignore Templates - 129+ .gitignore templates
- Dockerfile.io - Browse and download Dockerfile templates
- dockerignore.com - .dockerignore template generator
- gitignores.com - .gitignore template generator
This project is licensed under the MIT License - see the LICENSE file for details.
- Docker Community - For establishing and evolving best practices
- Open Source Maintainers - Whose work inspires our templates
- Contributors - Everyone who has helped improve this collection
- Users - For trusting these templates in production environments
Maintained by Dockerfile.io Β· View All Templates
Last Updated: 2026-01-23 Β· Template Count: 6