49

What exactly does Docker do with Union File system (like AUFS) to create the containers ? If Docker had to use a regular file system instead of a union file system what will be the disadvantages ?

I am looking for specific technical details/internals and not a high level answer.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Manohar
  • 3,865
  • 11
  • 41
  • 56

1 Answers1

56

It is used to:

  • avoid duplicating a complete set of files each time you run an image as a new container
  • isolate changes to a container filesystem in its own layer, allowing for that same container to be restarted from a known content (since the layer with the changes will have been dismissed when the container is removed)

That UnionFS:

implements a union mount for other file systems. It allows files and directories of separate file systems, known as branches, to be transparently overlaid, forming a single coherent file system.
Contents of directories which have the same path within the merged branches will be seen together in a single merged directory, within the new, virtual filesystem.

This allows a file system to appear as writable, but without actually allowing writes to change the file system, also known as copy-on-write

If you didn't have UnionFS, an 200MB image run 5 times as 5 separates containers would mean 1GB of disk space.

See more at "How does a Docker image work?".
For more technical details, see:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Plus, for those hosting the docker images on a SAN storage device on the backend, the humongous amount of cache hits must be a storage admin's dream. – CivFan Sep 25 '15 at 21:23