Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
github avatar

Multi Stage Dockerfile

  • 20.1k installs
  • 37.5k repo stars
  • Updated August 5, 2026
  • github/awesome-copilot

multi-stage-dockerfile is an agent skill that generates optimized multi-stage Dockerfiles producing smaller, more secure, reproducible container images for any language or framework.

About

multi-stage-dockerfile guides an agent to write efficient multi-stage Dockerfiles that produce smaller, more secure, reproducible container images. It separates a builder stage for compilation and dependency installation from a minimal runtime stage that copies only needed artifacts, and adds rules for base-image choice, layer caching, non-root users, and keeping build secrets out of the final image. A developer uses it when drafting or refactoring a production Dockerfile for any language or framework.

  • Separates builder and minimal runtime stages
  • Base-image rules: pinned tags, distroless, Alpine
  • Layer-caching and .dockerignore optimization
  • Security: non-root USER, no build secrets in final image
  • Language- and framework-agnostic

Multi Stage Dockerfile by the numbers

  • 20,130 all-time installs (skills.sh)
  • +813 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #14 of 1,435 DevOps & CI/CD skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

multi-stage-dockerfile capabilities & compatibility

Free skill; no API key required.

Capabilities
dockerfile generation · image optimization · container security · layer caching
Works with
docker
Use cases
devops · ci cd
Pricing
Free
From the docs

What multi-stage-dockerfile says it does

Use a builder stage for compilation, dependency installation, and other build-time operations
SKILL.md
Avoid running containers as root - use `USER` instruction to specify a non-root user
SKILL.md
Use multi-stage builds to avoid including build secrets in the final image
SKILL.md
npx skills add https://github.com/github/awesome-copilot --skill multi-stage-dockerfile

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs20.1k
repo stars37.5k
Security audit3 / 3 scanners passed
Last updatedAugust 5, 2026
Repositorygithub/awesome-copilot

How do I write a Dockerfile that produces a small, secure, reproducible production image?

Write optimized, secure multi-stage Dockerfiles for production container images.

Who is it for?

Developers who want an agent to draft or refactor production Dockerfiles following multi-stage best practices instead of bloated single-stage images.

Skip if: Orchestration, Kubernetes manifests, or CI pipeline config; it only covers writing the Dockerfile itself.

When should I use this skill?

The user wants to create, optimize, or review a Dockerfile, shrink a container image, or apply multi-stage build best practices.

What you get

Produces a multi-stage Dockerfile with a builder and minimal runtime stage, pinned base images, cache-friendly layers, and a non-root user.

  • Optimized multi-stage Dockerfile

By the numbers

  • 5 guidance sections (structure, base images, layers, security, performance)

Files

SKILL.mdMarkdownGitHub ↗

Your goal is to help me create efficient multi-stage Dockerfiles that follow best practices, resulting in smaller, more secure container images.

Multi-Stage Structure

  • Use a builder stage for compilation, dependency installation, and other build-time operations
  • Use a separate runtime stage that only includes what's needed to run the application
  • Copy only the necessary artifacts from the builder stage to the runtime stage
  • Use meaningful stage names with the AS keyword (e.g., FROM node:18 AS builder)
  • Place stages in logical order: dependencies → build → test → runtime

Base Images

  • Start with official, minimal base images when possible
  • Specify exact version tags to ensure reproducible builds (e.g., python:3.11-slim not just python)
  • Consider distroless images for runtime stages where appropriate
  • Use Alpine-based images for smaller footprints when compatible with your application
  • Ensure the runtime image has the minimal necessary dependencies

Layer Optimization

  • Organize commands to maximize layer caching
  • Place commands that change frequently (like code changes) after commands that change less frequently (like dependency installation)
  • Use .dockerignore to prevent unnecessary files from being included in the build context
  • Combine related RUN commands with && to reduce layer count
  • Consider using COPY --chown to set permissions in one step

Security Practices

  • Avoid running containers as root - use USER instruction to specify a non-root user
  • Remove build tools and unnecessary packages from the final image
  • Scan the final image for vulnerabilities
  • Set restrictive file permissions
  • Use multi-stage builds to avoid including build secrets in the final image

Performance Considerations

  • Use build arguments for configuration that might change between environments
  • Leverage build cache efficiently by ordering layers from least to most frequently changing
  • Consider parallelization in build steps when possible
  • Set appropriate environment variables like NODE_ENV=production to optimize runtime behavior
  • Use appropriate healthchecks for the application type with the HEALTHCHECK instruction

Related skills

FAQ

What does the multi-stage-dockerfile skill do?

It helps create efficient multi-stage Dockerfiles with a separate builder and minimal runtime stage, producing smaller, more secure, reproducible images.

How does it improve security?

It runs containers as a non-root USER, removes build tools from the final image, and uses multi-stage builds to avoid including build secrets.

Is Multi Stage Dockerfile safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

DevOps & CI/CDdeployinfra

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.