
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)
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
What multi-stage-dockerfile says it does
Use a builder stage for compilation, dependency installation, and other build-time operations
Avoid running containers as root - use `USER` instruction to specify a non-root user
Use multi-stage builds to avoid including build secrets in the final image
npx skills add https://github.com/github/awesome-copilot --skill multi-stage-dockerfileAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 20.1k |
|---|---|
| repo stars | ★ 37.5k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 5, 2026 |
| Repository | github/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
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
ASkeyword (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-slimnot justpython) - 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
.dockerignoreto 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
USERinstruction 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.