docker-optimizer

Analyze and optimize Dockerfiles for image size, security, and caching.

Updated Oct 27, 2025
One-click install
npx skills add https://github.com/CrazyDubya/claude-skills --skill docker-optimizer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: docker-optimizer
Source: https://github.com/CrazyDubya/claude-skills/tree/main/docker-optimizer
Command: npx skills add https://github.com/CrazyDubya/claude-skills --skill docker-optimizer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reviews Dockerfiles for best practices, security issues, and image size optimization, helping teams produce lean, secure containers and faster deployments.

Core Features & Use Cases

  • Best Practices: Enforces specific base image versions, minimizes layers, and optimizes build caching.
  • Security & Compliance: Detects common misconfigurations and guidance to avoid privilege issues and secrets exposure.
  • Size & Performance: Recommends multi-stage builds, and slim bases to reduce final image size and improve startup times.

Quick Start

Scan the Dockerfile in your project and return an optimized, multi-stage version with improved caching and security.

Frequently Asked Questions about docker-optimizer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce Docker image size in my Dockerfile?

Reduce image size by using multi-stage builds to discard build dependencies, choosing minimal base images, minimizing layers through command consolidation, and leveraging .dockerignore to exclude unnecessary files from the build context.

What are the security best practices for writing a Dockerfile?

Run containers as non-root users, use specific base image tags instead of latest, avoid copying secrets into images, scan for vulnerabilities, define HEALTHCHECK instructions, and minimize the attack surface by removing unnecessary packages and build tools.

How do I optimize Docker build caching to speed up deployments?

Order Dockerfile commands from least to most frequently changed, use precise COPY statements to avoid cache invalidation, separate dependency installation from application code, and leverage layer caching to accelerate container builds and CI/CD workflows.

Can multi-stage builds help with both security and performance?

Yes, multi-stage builds separate the compilation environment from the runtime environment, reducing final image size, removing build tools and dependencies, and lowering the security footprint while maintaining fast deployments.

What common Dockerfile misconfigurations should I avoid?

Avoid using untagged base images, running as root, copying entire directories unnecessarily, creating excessive layers, and failing to define health checks. These misconfigurations increase image size, slow deployments, and introduce security vulnerabilities.