What is copy-on-write (CoW) in containers?
IntermediateConceptImages, Layers & Storage Drivers
Answer
When a container modifies a file that lives in a lower read-only layer, overlay2 first copies the whole file up to the upperdir, then modifies the copy. The first write to a large file is slow and costs space; later writes are normal. Deleting a lower file creates a whiteout (a char device 0/0) in upperdir. Heavy write workloads should use volumes.
More on Images, Layers & Storage Drivers
What is a Docker image made of?BeginnerWhat is a layer and when is one created?BeginnerWhat is a union filesystem / OverlayFS?IntermediateWhy does deleting a file in a later `RUN` not shrink the image?IntermediateWhat storage drivers does Docker support and which is default?IntermediateWhat is the containerd image store and how does it differ from the classic graph driver store?Advanced