Interview Prep/Linux/Kernel Parameters, Namespaces & cgroups

What is overlayfs and why do containers use it?

AdvancedConceptKernel Parameters, Namespaces & cgroups
Answer

overlayfs merges read-only lower directories (image layers) with a writable upper directory into one merged view. Reads come from the topmost layer that has the file; the first write to a lower file triggers copy-up to the upper dir; deletes create whiteout files.

sudo mount -t overlay overlay \
  -o lowerdir=/l2:/l1,upperdir=/up,workdir=/work /merged

Many containers share the same lower layers on disk and in the page cache, which is why containers start fast and use little disk.

All Linux questions Roadmap: Linux

More on Kernel Parameters, Namespaces & cgroups