liveBook · Manning

Writable layer

As explained in Learn Docker in a Month of Lunches, Second Edition

A writable layer is the container-specific filesystem layer that records new and modified files above read-only image layers.

A writable layer gives each container its own filesystem space above shared, read-only image layers. Docker creates it when the container starts and removes it when the container is removed; stopping alone preserves it. section 6.1

Use the writable layer for container-local, short-lived changes:

  • New files are recorded in the layer and remain independent between containers. section 6.1
  • Edits to image files use copy-on-write: Docker copies the file into the writable layer before changing it. section 6.1
  • Cache data can fit here, but persistent application data belongs in a volume or another shared storage option. section 6.5

See container-local data disappear

Run two random-number containers and copy their output files to the host; the contents differ because each container has its own writable layer. Create another file-display container, copy input.txt into it, run it again, then remove the container. Its writable-layer data is transient and cannot be recovered after removal. section 6.1

Figure 6.2 The container filesystem is built from image layers and a writable layer.
figure

Inspect how shared image layers combine with one writable layer to present a single container filesystem. section 6.1

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains layer composition, lifecycle, and copy-on-write, while deferring operating-system-specific union-filesystem implementation.
Examples
Demonstrates independent random-number files, copied input files, container restarts, and data loss after removal.
What you can do after
Operate Docker storage by recognizing transient writable-layer data and selecting volumes for persistence.
How it connects
Connects writable layers with image layers, copy-on-write, union filesystems, bind mounts, and Docker volumes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.