In the previous recipe, we created a statically linked executable using the gcc builder container and then bundled the executable using the scratch image. Build pipelines with the builder pattern are very common because, during the build time, you will need heavyweight building and supporting tools. However, the resulting artifacts usually don't need those tools during execution time. Therefore, the artifacts are usually built using the appropriate runtime with additional capability and then the resulting artifacts are packaged with the runtime just enough to run the artifacts. Though this solution works very well, the complexity of this build pipeline is managed outside the Docker ecosystem through scripts. To address this complexity, Docker introduced a cool feature called multistage builds in version 17.05.
Docker's multistage build...