What is a Docker storage driver such as overlay2, and how does it combine image layers into a container's filesystem?
Answer
A storage driver is the component of the Docker daemon that stores image layers on disk and stacks them into the single filesystem a container sees, adding a thin writable layer on top. overlay2, built on the Linux kernel's OverlayFS, is the default and recommended driver on every current Linux distribution, and it gives containers fast startup and shared, read-only image layers through copy-on-write.
How overlay2 builds a container filesystem
OverlayFS merges directories. For each container Docker mounts:
lowerdir: the image's read-only layers, one directory per layer under /var/lib/docker/overlay2/.
upperdir: the container's own writable layer, initially empty.
workdir: scratch space OverlayFS needs for atomic operations.
merged: the unified view, mounted as the container's /.
Reads fall through to the highest layer containing the file. Ten containers from the same node:22 image share the same lower layers on disk and in the page cache, which is why starting the eleventh takes milliseconds and almost no extra space.
Copy-on-write and deletes
First write to an existing file triggers a copy-up: the whole file is copied from the lower layer into upperdir, then modified. Appending one line to a 2 GB file copies 2 GB.
Deleting a file that exists in a lower layer cannot actually remove it, so OverlayFS creates a whiteout entry in upperdir that hides it. This is why RUN rm in a later Dockerfile layer never makes the image smaller.
New files go straight into upperdir.
The driver landscape in 2026
Driver
Status
overlay2
Default and recommended for Linux (ext4 or xfs with ftype=1)
fuse-overlayfs
For rootless Docker on old kernels; modern kernels support native overlay rootless
btrfs, zfs
Used when the host filesystem is already Btrfs or ZFS
vfs
No copy-on-write, full copy per layer; testing only
aufs, devicemapper
Deprecated and removed from current Docker Engine releases
Docker is also moving from its classic "graph drivers" to the containerd image store, where containerd snapshotters (with overlayfs as the default) do the same job. Docker Desktop and recent Docker Engine releases use it by default for new installs. The concepts are identical; docker info shows which one you are on.
Why it matters in practice
Write-heavy data belongs in volumes. Databases, logs and uploads should go to a volume, which bypasses the storage driver and its copy-up cost entirely.
Container layer growth. Files written inside the container live in upperdir until the container is removed; docker ps -s shows each container's size.
Image hygiene. Because deletes are whiteouts, clean up in the same RUN that created the files (apt-get install ... && rm -rf /var/lib/apt/lists/*).
Changing driver hides data. Switching storage-driver in daemon.json makes existing images and containers invisible until you switch back.
overlay2 view of a running container. Read-only image layers are shared; only the top writable layer is per container.
merged: what the container sees as /: Unified view produced by OverlayFS.
upperdir: container writable layer: New files, copied-up files and whiteouts.
Layer 3: COPY app code: Read-only, shared by every container of this image.
Layer 2: RUN npm ci: Read-only dependency layer.
Layer 1: base image (node:22-slim): Read-only OS and runtime files.
Code examples
Inspecting the driver and a container's layers
# Which driver or image store is active
docker info --format '{{.Driver}}'
# Start a container and look at its overlay directories
docker run -d --name demo nginx:1.27-alpine
docker inspect demo --format '{{json .GraphDriver.Data}}' | tr ',' '\n'
# Size of each container's writable layer
docker ps -s --format 'table {{.Names}}\t{{.Size}}'
The `virtual` size includes shared image layers; the first number is only what this container wrote to its upperdir. On the containerd image store the GraphDriver fields look different.
Key points
overlay2 is the default and recommended storage driver on Linux.
Image layers are read-only lowerdirs; each container gets its own writable upperdir.
Modifying a lower-layer file copies the whole file up; deleting creates a whiteout.
aufs and devicemapper are deprecated and removed; the containerd image store uses snapshotters instead.
Put write-heavy data in volumes to bypass the storage driver.
Common follow-up questions
Why does deleting a file in a later Dockerfile layer not reduce image size?
What is the performance cost of copy-on-write for databases?
How does the containerd image store differ from classic graph drivers?
What happens to existing images when you change the storage driver?
Interview tips
Explain lowerdir, upperdir and merged in one breath; it proves you understand layers, not just the name overlay2.
Tie copy-on-write to a concrete consequence like database performance or image size.
Mentioning that aufs and devicemapper are gone shows you are current.
Concepts covered
overlay2, Copy-on-Write, Union Filesystem, Whiteout Files, containerd Snapshotter