docker-optimization

Optimize Dockerfiles and docker-compose configurations for smaller images and faster builds.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/somachak/claude-code-skills-db --skill docker-optimization-somachak
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: docker-optimization
Source: https://github.com/somachak/claude-code-skills-db/tree/main/skills/platform/docker-optimization
Command: npx skills add https://github.com/somachak/claude-code-skills-db --skill docker-optimization-somachak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Optimizes Dockerfiles and docker-compose configurations for image size, build speed, layer caching, and security hardening. Use when Dockerfiles are slow to build, images are bloated, containers run as root, or docker-compose files need production hardening. Covers multi-stage builds, .dockerignore strategy, secret handling, non-root users, healthchecks, and base-image selection for Node.js, Python, and compiled binaries. Different from shipping-containerized-services which handles deployment readiness.

Core Features & Use Cases

  • Multi-stage build optimization and sensible base-image selection for reduced image size
  • Security hardening through non-root users, healthchecks, and secret handling
  • Dockerfile and docker-compose best-practice guidance for faster builds and reliable caching

Quick Start

Run this skill against your Docker project to optimize a multi-stage build and apply non-root user and healthcheck policies.

Frequently Asked Questions about docker-optimization

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

FAQPage Schema
How do I reduce Docker image size using multi-stage builds?▼

Multi-stage builds reduce Docker image size by copying only compiled binaries or runtime artifacts from a builder stage into a minimal final image. This Skill optimizes Dockerfiles by applying multi-stage builds and selecting sensible base images across Node.js, Python, and compiled binaries.

How do I stop my Docker container from running as root?▼

To stop a Docker container from running as root, you must apply security hardening by creating a non-root user inside your Dockerfile. This Skill implements non-root user policies alongside healthchecks and secret handling to ensure secure container deployments.

What's the best way to speed up slow Docker builds?▼

Speeding up slow Docker builds requires optimizing layer caching and applying proper .dockerignore rules to exclude unnecessary context. This Skill provides Dockerfile and docker-compose best-practice guidance to achieve faster builds and reliable layer caching.

Does this Docker optimization guidance work for Python and Node.js projects?▼

Yes, this Docker optimization guidance supports Python, Node.js, and compiled binary projects. It adapts multi-stage builds, base-image selection, and secret handling guidelines to your specific project stack to ensure reproducible, secure container deployments.

Why are my Docker builds failing due to missing secret handling?▼

Docker builds can expose secrets if not properly handled during the build context and runtime stages. This Skill optimizes Dockerfiles by applying secure secret handling practices alongside non-root user policies and healthchecks to prevent sensitive data leaks.

Can I optimize docker-compose files for production hardening?▼

Yes, you can optimize docker-compose files for production hardening by applying non-root users, healthchecks, and reliable caching strategies. This Skill optimizes docker-compose configurations to reduce image size, speed up builds, and enforce security hardening.