Home Explore Blog CI



docker

2nd chunk of `content/manuals/build/cache/_index.md`
be9036fd90928cc951575b719e94daa5b4389affdc278f3f000000010000023c


Whenever a layer changes, that layer will need to be re-built. For example,
suppose you make a change to your program in the `main.c` file. After this
change, the `COPY` command will have to run again in order for those changes to
appear in the image. In other words, Docker will invalidate the cache for this
layer.

If a layer changes, all other layers that come after it are also affected. When
the layer with the `COPY` command gets invalidated, all layers that follow will
need to run again, too:

Title: Layer Changes and Cache Invalidation
Summary
When a layer in a Docker image changes, it needs to be rebuilt. For example, modifying a file copied by the `COPY` command invalidates the cache for that layer. Consequently, all subsequent layers that depend on the changed layer also need to be rebuilt.