copy on write
A rule where a shared file is only copied at the moment someone changes it.
In more detail
When a container reads a file, the union filesystem serves it from the highest layer that has it. When the container writes to a file from a lower layer, the file is first copied up into the writable layer and the change lands on that copy. Deleting writes a marker instead of removing anything. This keeps containers fast to start and cheap to store.
Related terms
- union filesystem — A filesystem that stacks several directories on top of each other and shows them as one.
- writable layer — The thin layer on top of an image where a running container writes its changes.
- whiteout file — A marker in a higher layer that says a file from a lower layer has been deleted.
- layer — One read-only slice of an image that records the files a single build step added, changed or deleted.
Taught in
- Union Filesystems, Images And Writable Layers — Docker Architecture & Production Containers