What is a container overlay filesystem? Understanding image layers and the writable layer
A container overlay filesystem presents several read-only image layers and a container-specific writable layer as one filesystem. A container can read image files and record its own changes without modifying the source image layers. New or changed files appear in that container's view, but the writable-layer data may disappear when the container is removed.
What is a container overlay filesystem? Understanding image layers and the writable layer
A container overlay filesystem presents several read-only image layers and a container-specific writable layer as one filesystem. A container can read image files and record its own changes without modifying the source image layers. New or changed files appear in that container's view, but the writable-layer data may disappear when the container is removed.
This article explains the overlay model for Linux containers and Docker storage. “Overlay filesystem” may refer to the Linux kernel's OverlayFS, Docker's classic overlay2 storage driver, or containerd's overlayfs snapshotter. These names are related but refer to different layers of the stack. As of 2026, fresh Docker Engine 29.0+ installations use the containerd image store by default, so do not assume every Docker host uses overlay2.
How one filesystem view is formed
Linux OverlayFS combines a lower directory tree and an upper directory tree into a merged view. A runtime can use read-only image layers as lower content and a container's changes as its upper content. workdir is used internally by OverlayFS. Reads go through the merged view, so the application usually does not need to know which layer supplied a file.
Merged filesystem seen by the container process
▲
┌───────────┴───────────┐
│ upper: this container's writes │ ← edits, new files, deletion markers
├────────────────────────┤
│ lower: read-only image layers │ ← may be shared by containers
└────────────────────────┘The point is that containers can reuse common read-only image content while keeping their writes in separate upper layers. This is a conceptual diagram, not a claim about a runtime's exact disk layout or mount paths.
If the same filename exists in upper and lower, the upper file is shown. When both layers contain a directory, their directory entries can be merged. For example, changing /etc/app.conf affects the view of that container without overwriting the shared image file.
First modification: copy-up
Image layers are read-only. When a process first modifies a file that exists in a lower layer, OverlayFS can copy that file into the upper layer and apply the change there. This is called copy-up. Needed parent directories and metadata are also represented in the upper layer. Later writes use the upper copy.
Suppose, hypothetically, that an image contains a 500 MB log-template file and an application changes one line at startup. The first write may require copying the whole file. This illustrates the mechanism; actual cost depends on runtime, kernel, backing filesystem, and access pattern. Large existing files or frequently written data in a container's writable layer can increase first-write latency and storage use.
Deletion also does not edit the lower image layer. Because image layers can be shared, the runtime can put a whiteout marker in the upper layer to hide a lower file in the merged view. An opaque-directory marker can hide lower directory contents. These are implementation details; do not edit or remove them manually inside Docker's data directory.
Image layers, writable layer, and volumes
| Location | Typical role | After container removal | Suitable data |
|---|---|---|---|
| Image layers | Read-only files from the image build | Remain while the image is retained | Static application files shareable by containers |
| Container writable layer | Files created or changed by that container | May be removed with the container | Re-creatable temporary state or cache |
| Volume or bind mount | Data path separate from container filesystem lifetime | Can persist beyond container removal | Database files, uploads, logs, and other state to preserve |
This describes typical roles, not a backup guarantee. Persistence depends on volume management, backups, host policy, and orchestration. Important application data stored only in the writable layer can be lost when replacing or deleting a container. Put persistent state in a volume or external storage and design backups and recovery separately.
Docker documentation describes storage drivers as managing image layers and container writable-layer data; the writable layer does not persist after container deletion. Volumes are a separate persistence path. Do not treat them as the same storage mechanism.
Which backend does Docker use?
Distinguish the Linux filesystem from Docker's storage backend names:
**OverlayFS:** the Linux kernel's merged filesystem implementation.
**`overlay2`:** the name of Docker Engine's classic storage driver.
**`overlayfs` snapshotter:** the snapshot implementation used by Docker's containerd image store. Docker documents this as the default backend for fresh Engine 29.0+ installations. Docker also documents that the containerd image store cannot be used with `userns-remap`.
To identify a host's configuration, inspect the storage information in docker info, along with the Docker Engine version and settings. With the containerd image store, classic overlay2 commands and paths may not apply. Do not directly edit, move, or delete files under Docker-managed /var/lib/docker or /var/lib/containerd. Switching backends can temporarily hide images and containers from the other backend even though their data remains on disk. Before switching, review the official migration procedure, backups, and image export or registry options.
What operators can inspect
On a Linux Docker Engine host, these commands provide read-only information:
docker info
docker system df
docker inspect --format '{{.GraphDriver.Name}} {{json .GraphDriver.Data}}' CONTAINERUse docker info to inspect the storage driver and backing filesystem. docker system df reports Docker's accounting of image, container, and volume space. docker inspect may expose driver-specific information for a container, but fields can vary or be empty with a different backend. None of this output is a reason to edit internal storage files directly.
To limit writable-layer growth, move data that grows repeatedly—such as logs, caches, or database files—to an appropriate volume or external store. Review Dockerfile build steps so large temporary files are not left in image layers. Deleting a file in a later image layer does not automatically shrink earlier layers. Image-size optimization and runtime data persistence are separate concerns.
Practical takeaway
Overlay storage lets containers share read-only image content while isolating each container's changes. The trade-offs include copy-up cost on first modification and a writable layer that may be short-lived. Put data that must survive container removal in a volume or another persistent store. When diagnosing storage, identify the actual backend first and avoid manipulating Docker-managed data directories directly.
References
[Docker Engine: OverlayFS storage driver](https://docs.docker.com/engine/storage/drivers/overlayfs-driver/)
[Docker Engine: Storage drivers](https://docs.docker.com/engine/storage/drivers/)
[Docker Engine: containerd image store](https://docs.docker.com/engine/storage/containerd)
[Linux kernel documentation: Overlay Filesystem](https://docs.kernel.org/filesystems/overlayfs.html)
Public documentation checked on 2026-11-23. Docker's storage backend depends on version and installation or migration history; inspect the actual host.