4. What is OverlayFS?
• OverlayFS is implementation of Union File System
• OverlayFS stacks multiple Directory/Files to construct one
directory tree, and it can save volumes
• OverlayFS is composed of three layers
Reference: https://www.datalight.com/blog/2016/01/27/explaining-overlayfs-%E2%80%93-what-it-does-and-how-it-works/
5. Three Layers of OverlayFS
• Lower is R/O layer
• Upper is R/W layer
• Overlay merge Lower and Upper, and you can handle data
without being aware of layers
Lower Upper Overlay
6. OverlayFS, as a FileSystem
• File Read: Read from top (if no it exist, read from bottom)
• File Write(if exist Upper): normal write
• File Write(if exist only Lower): Copy file into Upper
Lower Upper Overlay
Read
Read
Lower Upper Overlay
Write
Copy
Read Write
Write
7. OverlayFS, as a FileSystem
• File Remove: if it exist on Lower, overlay will create
whiteout file
• If you just delete file exist on Upper, you can read the file
from Lower
Lower Upper Overlay
Remove
Remove
Lower Upper Overlay
Can not ReadRemove
whiteout file
Create
Can not Read
10. Background of Docker Storage Driver
• Docker consists of Image and Container
• Image is a bundle of R/O layers
• Container is a bundle of Image and thin R/W layers on
Image
Dockerfile
Image
R/O layer
FROM ubuntu:latest
COPY ./sample.sh /
RUN apt-get update..
RUN curl https://go..
Container
R/O layer
FROM ubuntu:latest
COPY ./sample.sh /
RUN apt-get update..
RUN curl https://go..
R/W layer
Build Run
11. What is Docker Storage Driver?
• Docker Storage Driver stacks these layers to make them
appear single
Reference: https://docs.docker.com/v17.09/engine/userguide/storagedriver/imagesandcontainers/
12. Why Docker Storage Driver is used?
• R/O Files should share with others (same as Union FS
philosophy)
Reference: https://docs.docker.com/v17.09/engine/userguide/storagedriver/imagesandcontainers/
14. OverlayFS, as a Docker Storage Driver
• Docker Storage Driver itself is like Union FS
• It has many implementation (overlay2, aufs,
devicemapper, btrfs, and etc...), overlay is one of them
• Docker official site recommend overlay2 driver
• overlay2 can use multiple lower (overlay can only use
one lower)
Reference: https://docs.docker.com/storage/storagedriver/select-storage-driver/
16. Conclusion
• OverlayFS is an File System consisting of R/O
layer(Lower), R/W layer(Upper), and an Overlay layer
merge Lower and Upper, which can save volumes
• Docker uses Image as R/O layer(Lower) and Container
as stack(Overlay) of Image and R/W layer(Upper), which
can save volumes