Dockerfile Best Practices
Dockerfile best practices, layer optimization, multi-stage builds, security, and image size reduction.
Install
/plugin marketplace add sethdford/claude-skillsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add sethdford/claude-skills --skill dockerfile-best-practicesgit clone --depth 1 https://github.com/sethdford/claude-skills.git /tmp/claude-skills
mkdir -p ~/.claude/skills
cp -r /tmp/claude-skills/engineer/devops-practices/skills/dockerfile-best-practices ~/.claude/skills/dockerfile-best-practicesPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Dockerfile Best Practices Writing efficient, secure container images. ## Context You are writing a Dockerfile. Optimize for size, build speed, and security. ## Domain Context - **Layers**: Each line creates a layer; fat layers are slow to build/push - **Caching**: Earlier layers cache better; put changeable stuff at end - **Multi-Stage**: Separate build and runtime images; smaller final image - **Security**: Don't run as root; minimal base image - **Size**: Alpine < Ubuntu < Debian; watch for bloat ## Instructions 1. **Choose Base Image**: Alpine (small), Debian (compatible), Ubuntu (big) 2. **Install Essentials**: Only what's needed; remove package caches 3. **Use Multi-Stage**: Build stage, runtime stage; small final image 4. **Order Statements**: Stable first, changeable last (maximize caching) 5. **Run as Non-Root**: Create user, switch with USER 6. **Health Checks**: HEALTHCHECK for container orchestrators 7. **Documentation**: Comments explain why, not what ## Anti-Patterns - Fat images (>500MB); slow to push/deploy - Running as root; security risk - Single huge layer; no caching benefit - Installing dev tools in production; unnecessary bloat - Many layers; each adds overhead ## Further Reading - Docker documentation best practices - Google Cloud dockerfile best practices - Container security guidelines
Details
- Skill name
dockerfile-best-practices- Repository
- sethdford/claude-skills
- Path
engineer/devops-practices/skills/dockerfile-best-practices/SKILL.md- License
- MIT
- Repo updated
- 11 March 2026
FAQ
What does the Dockerfile Best Practices skill do?
Dockerfile best practices, layer optimization, multi-stage builds, security, and image size reduction.
How do I install the Dockerfile Best Practices skill?
Claude Code plugin: /plugin marketplace add sethdford/claude-skills. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Dockerfile Best Practices popular?
It lives in sethdford/claude-skills, which has 48 GitHub stars and 10 forks.
Related skills
A B Test Design
48sethdford/claude-skills
Design rigorous A/B tests with hypotheses, variants, metrics, and sample size calculations.
A B Test Design Pm
48sethdford/claude-skills
Analytics and experimentation skill for product managers.
Abuse Case Design
48sethdford/claude-skills
Design abuse cases (negative use cases) showing how attackers misuse system features. Use when identifying attacks that exploit intended functionality or business logic flaws.
Fitness Function Design
48sethdford/claude-skills
Design metrics that measure architecture health (coupling, modularity, scalability). Automate fitness function checks in CI/CD. Use when establishing quality gates or measuring architectural degradation.
Deployment Topology
48sethdford/claude-skills
Plan container orchestration, load balancing, high availability, and scaling. Design deployment topologies for production systems. Use when architecting deployment infrastructure or modernizing deployment practices.
Infrastructure As Code
48sethdford/claude-skills
Terraform, CloudFormation, reproducible infrastructure, version control, and IaC best practices.
Browse the most popular Claude skills, all devops & cloud skills, or write your own with the skills generator.