dockerfile-optimize

Refactors Dockerfiles into multi-stage builds with distroless images and non-root execution.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill dockerfile-optimize
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dockerfile-optimize
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/dockerfile-optimize
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill dockerfile-optimize

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses bloated container images, slow build times, and security vulnerabilities by applying industry-standard hardening and optimization techniques to Dockerfiles.

Core Features & Use Cases

  • Multi-stage Optimization: Automatically refactors Dockerfiles to separate build-time dependencies from runtime artifacts.
  • Security Hardening: Implements non-root user execution, distroless base images, and secret management to reduce the attack surface.
  • Build Performance: Configures layer caching and efficient instruction ordering to minimize build times.
  • Use Case: Use this when your production image size exceeds 500MB or when you need to ensure your container meets security compliance standards before deployment.

Quick Start

Analyze the current Dockerfile in this directory and provide a refactored version that implements multi-stage builds and non-root security best practices.

Frequently Asked Questions about dockerfile-optimize

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

FAQPage Schema
How do I optimize a Dockerfile for smaller image size and faster build performance?

You can optimize Dockerfiles by applying multi-stage builds to separate build-time dependencies from runtime artifacts, using distroless base images, and configuring layer caching to minimize image size and build times.

What's the best way to secure a Docker container against vulnerabilities?

To secure a Docker container, implement non-root user execution, switch to distroless base images, and apply secret management strategies to significantly reduce the container's attack surface.

When do I need to use multi-stage builds in my containerization workflow?

You need multi-stage builds when your production image exceeds 500MB or requires strict separation of build-time dependencies from final runtime artifacts to ensure a minimal and secure container.

How does layer caching affect Docker build performance?

Layer caching affects Docker build performance by allowing efficient instruction ordering to reuse previously built layers, which minimizes rebuild times and speeds up the overall containerization workflow.

Can I use distroless base images with BuildKit for reproducible builds?

Yes, you can use distroless base images with BuildKit alongside digest pinning to create minimal containers that satisfy requirements for non-root execution and highly reproducible builds.

Why does my Docker image exceed 500MB and how can I reduce it?

Your Docker image likely exceeds 500MB due to unnecessary build-time dependencies bundled into the runtime image, which you can reduce by refactoring to multi-stage builds and using distroless base images.