What are the three ways to persist or share data with a container?
BeginnerConceptVolumes & Bind Mounts
Answer
- Volume: managed by Docker under
/var/lib/docker/volumes, portable, driver-pluggable. Preferred for persistent data. - Bind mount: maps a host path into the container; depends on host layout. Good for dev and config.
- tmpfs: in-memory, never written to disk, gone when the container stops.
More on Volumes & Bind Mounts
Volume vs bind mount: when do you pick which?BeginnerWhat is the difference between `-v` and `--mount`?BeginnerWhat is an anonymous volume and how do you find leftovers?IntermediateHow does a new named volume get populated?IntermediateHow do you back up and restore a named volume?IntermediateWhere is a named volume physically stored and can you edit it directly?Intermediate