Introduction
Sometimes, building a Docker image requires compiling code or preparing files before creating the final image. Before Docker had multi-stage builds, developers used the builder pattern to separate the build steps into different images to keep the final image small and clean.
When you need to compile source code before running your app in a Docker container.
When you want to keep your final Docker image small by excluding build tools.
When your Docker version does not support multi-stage builds.
When you want to reuse a build image for multiple final images.
When you want to separate build and runtime environments clearly.