When we create Docker images using Dockerfiles, we specify instructions inside them. Each instruction creates a new intermediate image layer. When we first build the Image, it executes all the instructions one by one.
When we try to build it once again after making any changes, it uses the cache from the previous build for all unchanged instructions. As soon as it encounters a changed instruction, the cache is broken for this, and all subsequent instructions are executed freshly.