What is Multi-stage Build?
A Dockerfile pattern using multiple FROM stages to create smaller, leaner final images.
A multi-stage build uses multiple FROM instructions in a single Dockerfile, where each stage can have a different base image. Build-time dependencies (compilers, test tools, build tools) exist only in builder stages and never appear in the final image. The last stage copies only the compiled artifacts from earlier stages. This can reduce image sizes from 1GB to under 100MB. Multi-stage builds are the standard approach for compiled languages (Go, Java) and JavaScript apps.
Deep Dive Guide
docker security best practices
Free Tool
dockerfile linter
Related Terms
More Containers Terms
BuildKit
Next-generation Docker image build engine with parallel builds and better caching.
Container
A lightweight, isolated process that packages code and its dependencies together.
Container Image
A read-only template with layers used to create containers.
Container Registry
A repository for storing, versioning, and distributing container images.
Dockerfile
A text file with instructions for building a container image layer by layer.
Docker Compose
A tool for defining and running multi-container Docker applications using YAML.
Test your knowledge of Multi-stage Build and 130 other DevOps concepts