Reusing image layers

As we already know, a Docker image consists of a series of layers combined with the union filesystem of a single image. When we work on building our Docker image, the preceding instructions in our Dockerfile are examined by Docker to check whether there is an existing image in its build cache that can be reused instead of creating a similar or duplicate image for these instructions.

By finding out how the build cache works, we can greatly increase the speed of the subsequent builds of our Docker images. A good example of this is when we develop our application's behavior; we will not add dependencies to our application all of the time. Most of the time, we will just want to update the core behavior of the application ...

Get Docker High Performance - Second Edition now with O’Reilly online learning.

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