Introduction
Sometimes you need to build a Docker image in steps, using one image to prepare files and another to run the app. Multiple FROM statements let you do this in one Dockerfile, making your images smaller and cleaner.
When you want to compile code in one image and run it in a smaller image.
When you need to separate build tools from runtime environment to reduce image size.
When you want to copy only the necessary files from a build stage to the final image.
When you want to create multi-stage builds to optimize Docker images for production.
When you want to keep your Dockerfile simple but efficient by combining build and runtime steps.