Docker image optimizer devops
Skill vivek-viswanat/dev-arsenal/skills/docker-image-optimizer-devops
A curated library of production-ready skills and tools designed to supercharge ClaudeCode, AntiGravity, Cline, RooCode and other agentic IDE extensions.
npx -y skills add vivek-viswanat/dev-arsenal --skill docker-image-optimizer-devopsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 4 stars4 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Audits and refactors Dockerfiles to reduce image size, improve security and speed up build times.
SKILL.md
2.0 KB, as published. Nobody here has run it
Context
Use this skill when:
- Creating a new
Dockerfile - A user complains about "slow builds" or "large images"
- Reviewing container security (reducing attack surface)
Optimization Pillars
1. Multi-Stage Strategy (The 2026 Standard)
- Separate Build from Runtime: Use a heavy image (with compilers/SDKs) for building, but copy ONLY the final binary/artifacts into a minimal runtime image (Alpine or Scratch).
- Named Stages: Use
FROM base AS builderfor readability.
2. Base Image Selection
- Prefer Minimal: Default to
alpine(≈5MB) ordebian-slim(≈30MB) overubuntu:latest(≈75MB). - Distroless: For production, suggest
gcr.io/distrolessto remove all shells and package managers.
3. Layer Management & Caching
- Order Matters: Place instructions that change least often (like
RUN apt-get update) at the top. Place source codeCOPYcommands at the bottom. - Atomic RUNs: Combine related commands using
&&and\to prevent intermediate layer bloat. Example:RUN apt-get update && apt-get install -y --no-install-recommends pkg && rm -rf /var/lib/apt/lists/*
4. Dependency Hygiene
- No-Install-Recommends: Always use
--no-install-recommendswithapt. - Cache Cleaning: Remove package manager caches in the same layer as the installation.
- Production Only: Ensure
devDependenciesor build-only headers never reach the final stage.
5. The .dockerignore File
- Exclusion: Every Docker project MUST have a
.dockerignoreto prevent.git,node_modules,tests/, and local logs from leaking into the build context.
Instructions for the Agent
- When a user provides a Dockerfile, perform a Size Audit first.
- If the image is single-stage, provide a Refactored Multi-Stage Version.
- Check for "Magic Versions" and suggest pinning specific tags (e.g.,
node:22.1.0-alpineinstead ofnode:latest).