the .dockerignore file
The .dokerignore file
May 16, 2023
How to fix the compile error?
How to fix the compile error?
May 30, 2023

May 23, 2023

Docker Layer Caching

When building a Docker image, each line in the _dockerfile_ represents the building of a layer in the image layer stack, and when we run the `docker build -t [image_name]` command, Docker checks for any modification in each layer and decides whether to add the layer from scratch or to load it from the file system's cache, hence saving you significate build time.

One consequence of this feature is that a change in a certain layer forces docker not only to re-build the modified layer itself, but also the layers that come after it.

Example:

_node_ developers should place the `RUN npm install` command before the `COPY . .` command to ensure that a change in the source code does not require a re-run of `npm install` and a redundant update of _npm_ packages.

#Before
COPY . .
RUN npm install
#After
COPY package.json .
RUN npm install
COPY . .
Docker Layer Caching
This website uses cookies to improve your experience. By using this website you agree to our Data Privacy Statement
Read more