8.1.2.5 Runtime Write Performance
A focused guide to Runtime Write Performance, connecting core concepts with practical Docker and container operations.
Runtime write performance refers to how quickly a container can actually write data to its filesystem, which can be affected by the overhead of the layered filesystem mechanism itself, particularly the file copy-up cost for modifying files originating from read-only layers.
Measuring Write Performance Within the Writable Layer
Writing to a file that already exists entirely within the writable layer (one that has already undergone copy-up, or was created fresh within the container) performs comparably to writing on an ordinary, non-layered filesystem.
docker exec myapp dd if=/dev/zero of=/tmp/testfile bs=1M count=100
This measures write performance for a file created fresh in the writable layer, unaffected by any copy-up overhead.
Measuring the Additional Cost of Copy-Up
Modifying a large file inherited from a read-only layer for the first time incurs the additional copy-up cost on top of the actual intended write.
time docker exec myapp sh -c "echo 'x' >> /app/large-inherited-file.dat"
Comparing this against an equivalent modification to a file already in the writable layer reveals the specific overhead copy-up introduces.
Why Volumes Bypass This Overhead Entirely
A mounted volume's storage is not subject to the layered filesystem's copy-up mechanism at all, since it bypasses the union filesystem entirely — for workloads with substantial or performance-sensitive write activity, this can provide a meaningful performance advantage.
docker run -d -v fast-data:/app/data myapp:1.0
docker exec myapp dd if=/dev/zero of=/app/data/testfile bs=1M count=1000
When This Performance Consideration Actually Matters
For applications with modest, infrequent writes, this overhead is rarely noticeable; it becomes a genuinely relevant consideration specifically for write-heavy workloads, particularly those frequently modifying large files inherited from the image itself.
docker stats myapp
Why Runtime Write Performance Matters
Understanding the specific overhead the layered filesystem can introduce for certain write patterns helps explain otherwise puzzling performance characteristics, and informs the decision to route write-heavy or performance-sensitive data through a volume rather than relying on the container's own writable layer.