layer
What is layer?
layer: Each Dockerfile instruction creates a stacked, cached filesystem layer. Layers are shared between images, which is why pulls and builds are fast. A Docker image is built from layers. Each instruction in a Dockerfile, such as RUN, COPY or ADD, creates a new read-only layer on top of the previous one.
Frequently asked questions about layer
How is layer used in practice?
Layers are cached and shared. If nothing changed in a step, Docker reuses the cached layer, which makes rebuilds fast. Images built on the same base share those base layers on disk and when pulling.
What should you keep in mind with layer?
Order your Dockerfile to make the most of this. Put steps that rarely change, like installing system packages and dependencies, before steps that change often, like copying your source code. Clean up in the same RUN step that created the files, because deleting files in a later layer does not make the image smaller. docker history shows each layer and its size.
What does an example of layer look like?
docker history myapp:1.0 At a glance
| Category | Docker |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |