What is Union Mounts and how it works? Explained with Images!

  • Union mount is a type of a filesystem that can create an illusion of merging contents of several directories into one without modifying its original (physical) sources.
  • Union mount or union filesystem is not the filesystem type, but rather a concept with many implementations.
  • UnionFS, aufs, OverlayFS, ZFS, and Btrfs are different implementations of union file systems.
  • Docker only needs to create thin layer on top of the image and rest of it can be shared between all the containers.
  • Union filesystem also provides isolation, because containers have read-only access to the shared image layers.
  • LowerDir: Is the directory with read-only image layers separated by colons
  • MergedDir: Merged view of all the layers from image and container
  • UpperDir: Read-write layer where changes are written
  • WorkDir: Working directory used by Linux OverlayFS to prepare merged view