DEV Community

Zhalok Rahman
Zhalok Rahman

Posted on Edited on

OverlayFS: The Backbone of Container Storage

Where do the files required by containers actually live?

They are arranged in directories inside
/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots

If you list the contents of this directory you will find a list of directories

These directories are called layers and this exactly the overlayfs

All of these layers are read-only except for one. Whenever you make a new build, a new layer is created and the existing layers are re-used possible

Your kernel decides which of these layers can be accessed by which processes and this is defined in the process config inside the host os

If we inspect the directories we can find the files used by the containers

Why we need these layers?

The layers can be used as a re-usable cache
Imagine you have 5 containers with the same base image, then instead of pulling 5 set of files, we can simply use them from the existing layer.

The layers are immutable. Meaning containers can not change in the existing layers but if there is any change required then a new layer is created

This way we avoid unnecessary duplication with mutation safety

This also helps us building efficient production containers with multi-layer builds

Top comments (0)