Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, How Containers Work!! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript". get the zine!
read the transcript!

how layers work: mount -t overlay

smiling stick figure with curly hair: can you combine these 37 layers into one filesystem?

linux, represented by Tux the penguin: yes! Just run mount —t overlay with the right parameters!

mount -t overlay has 4 parameters

  • lowerdir: list of read-only directories
  • upperdir: directory where writes should go
  • workdir: empty directory for internal use
  • target: the merged result

upperdir: where all writes go

when you create, change, or delete a file, it’s recorded in the upperdir.

usually this starts out empty and is deleted when the container exits

lowerdir: the layers. read only.

smiling stick figure with curly hair: you can run $ mount -t overlay inside a container to gee all the lower dirs that were combined to create its filesystem!

here’s an example!

$ mount -t overlay overlay -o
     lowerdir=/lower , upperdir=/upper , workdir=/work /merged
$ ls /upper
cat.txt dog.txt
$ ls /lower
dog. txt bird.txt
$ ls /merged
cat.txt dog.txt bird.txt

the merged version of dog.txt is the one from the upper directory