Allows to build multiple images in one Dockerfile and pass data between them to optimize the final build.
Useful to optimize image sizes without compromising readability as much.
Build can be stopped at the specific target:
docker build --no-cache -f Dockerfile --target stage2 .
Starting from v23.0 BuildKit is enabled by default, and the stage1
in the example above will be skipped.
Links:
See also