Skip to content

overlay2: layers and copy-on-write

Select an icon to see what it is.

Step 4 of 6

Changing an image file copies it up

To modify a file that lives in an image layer, overlayfs first copies the whole file into the upper layer, then applies the change there. This is copy-on-write. The original in the image layer stays as it was.

Upper layer after the first write

/var/lib/docker/overlay2/<container>/diff/etc/nginx/nginx.conf (full copy, now modified)
lower layer copy: unchanged