Sobes.tech
Middle

Mis on kiht Dockeris ja milleks see on vaja?

sobes.tech AI

Vastus AI-lt

In Docker, a layer is a separate level of the filesystem that is created when executing each instruction in the Dockerfile (e.g., RUN, COPY, ADD). Each layer contains changes compared to the previous layer, such as added or modified files.

Layers are necessary for:

  • Caching: when building an image, Docker reuses unchanged layers, speeding up the build process.
  • Storage optimization: layers can be used by multiple images, saving space.
  • Change management: allows tracking and reverting changes.

Example: if the Dockerfile first copies code and then installs dependencies, when only the code changes, Docker will rebuild only the top layer, without touching the dependencies layer.