CONTAINERS / A CONCEPT NOTE
Volumes & Persistence
data that survives restarts
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
Container filesystems are ephemeral. Writable layers are destroyed when a container stops. Volumes mount a directory on the host's physical disk directly into the container filesystem.
02 / FOLLOW THE MECHANISM
How data persistence flows
Volume Define
user specifies mounting directory path (e.g. /var/lib/mysql) to host path.
Mount syscall
container runtime intercepts filesystem startup and mounts host directory.
Writes
application writes database transactions inside mount folder.
Recreation
container is deleted and recreated; new container mounts same directory, retaining all data.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
list local persistent volumes
docker volume lsmount volume db_data inside database container
docker run -v db_data:/var/lib/mysql mysql05 / CHECK YOURSELF
Could you explain Volumes & Persistence to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Containers & KubernetesOrchestrationwhy one container is never enough