Skip to content

Multi-stage builds: compile big, ship small

Select an icon to see what it is.

Step 5 of 6

Only the final stage is the image

The tagged image is made from the final stage's layers alone. The builder stage stays in the build cache and is not part of web:1.0. docker history shows alpine's layers plus the COPY layer, with no Go toolchain.

$ docker history web:1.0

docker image inspect web:1.0 (excerpt)

{
"RootFS": {
"Layers": [
"sha256:<alpine>"
"sha256:<web-binary>"
]
}
"Config": {
"Cmd": [
"/web"
]
}
}