Volumes and Persistent Data
A container's writable layer is ephemeral — it is deleted together with the container. In this lesson we see how to keep data that must survive: a named volume managed by Docker that outlives container removal and recreation, and a bind mount that maps a host directory and is great for local develop
A container's layer is like a scratch notebook you toss in the bin when done. A volume is like a safe-deposit box: even after you throw away the notebook, the papers in the box stay there waiting for the next container.
- volume
- A Docker-managed storage area (named volume) attached to a container with -v name:/path that survives even when the container is removed and recreated.
- bind mount
- Mapping a directory from the host machine to a path in the container with -v /host/path:/container/path, great for local development since file changes show up immediately on both sides.
- writable layer (ephemeral)
- The thin layer on top of the image where a container writes files at runtime. It is deleted with the container, so data written only there is lost.