Dockerfile Optimizer
Optimizes Dockerfiles for smaller image sizes and faster builds, improving deployment efficiency and reducing storage costs.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add dockerfile-optimizer npx -- -y @trustedskills/dockerfile-optimizer
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"dockerfile-optimizer": {
"command": "npx",
"args": [
"-y",
"@trustedskills/dockerfile-optimizer"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
The Dockerfile Optimizer skill helps AI agents build optimized, secure, and cache-efficient Docker images based on production best practices. It analyzes existing Dockerfiles, identifies areas for improvement, and implements techniques like multi-stage builds, efficient layer caching, and the use of smaller base images to reduce image size and improve build speed. The skill also incorporates security hardening measures such as creating non-root users and minimizing permissions.
When to use it
- You need to reduce the size of your Docker images for faster deployments and lower storage costs.
- Your Docker builds are slow, and you want to improve their efficiency.
- You're looking to enhance the security posture of your containerized applications.
- You’re working with Node.js, Python, Go, Rust, or Java projects and need guidance on optimal base image selection.
- You want to automate the process of creating multi-stage Docker builds.
Key capabilities
- Dockerfile Analysis: Identifies optimization opportunities within existing Dockerfiles.
- Multi-Stage Builds: Separates build and runtime environments for smaller images.
- Layer Caching Optimization: Orders instructions in the Dockerfile to maximize cache utilization.
- Image Size Minimization: Recommends and utilizes slim base images (e.g.,
node:20-slim,node:20-alpine,gcr.io/distroless/nodejs20). - Security Hardening: Creates non-root users and minimizes permissions within containers.
- Health Check Configuration: Adds health checks to ensure container monitoring.
- Base Image Recommendations: Provides guidance on selecting appropriate base images for various languages (Node.js, Python, Go, Rust, Java).
Example prompts
- "Optimize this Dockerfile: [Dockerfile content]"
- "Suggest a smaller base image for my Node.js application."
- "Create a multi-stage Dockerfile for a Next.js project."
Tips & gotchas
- The skill provides recommendations based on common best practices; review the generated Dockerfiles carefully before deploying to production.
- Consider the trade-offs between image size and functionality when selecting base images (e.g., Alpine is smaller but may require additional dependencies).
- For maximum security, consider using distroless base images like
gcr.io/distroless/nodejs20.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.