dockerfile-best-practices
Installation
SKILL.md
Dockerfile Best Practices
Apply these rules when writing, reviewing, or optimizing any Dockerfile.
Base Images
- Use minimal base images:
alpine,slim,distroless, orscratch - Compiled languages (Go, Rust): use
scratchimages - Interpreted languages (Node.js, Python): use
alpineorslim(runtime needed) - Always use multistage builds to separate build-time and runtime dependencies
Image Optimization
Layer Caching
Order layers from least-changing to most-changing: