
Multistage builds added a couple of new syntax concepts. All other BuildKit based builders support these patterns as well. If you use these patterns, enabling BuildKit is strongly recommended. I’ve marked these cases under the individual examples. For example, BuildKit efficiently skips unused stages and builds stages concurrently when possible. While all the patterns here work with the older builder as well, many of them run much more efficiently when BuildKit backend is enabled. The latest Docker versions come with new opt-in builder backend BuildKit.

If you are new to multistage builds you probably want to start by reading the usage guide first. In this blog post, I’ll show some more advanced patterns that go beyond copying files between a build and a runtime stage, allowing to get most out of the feature. Multistage builds feature in Dockerfiles enables you to create smaller container images with better caching and smaller security footprint.
