Using multi-stage builds

In this, the final part of our journey into using Dockerfiles and building container images, we will look at using a relatively new method for building an image. In the previous sections of this part of the chapter, we looked at adding binaries directly to our images either via a package manager, such as Alpine Linux's APK, or, in the last example, by downloading a precompiled binary from the software vendor.

What if we wanted to compile our own software as part of the build? Historically, we would have had to use a container image containing a full build environment, which can be very big. This means that we probably would have had to cobble together a script that ran through something like the following process: ...

Get Mastering Docker - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.