What is the difference between `-v` and `--mount`?
BeginnerConceptVolumes & Bind Mounts
Answer
--mount is explicit key=value and clearer; -v src:dst:opts is terse. The key behavioral difference: with -v a missing host path for a bind mount is auto-created as a root-owned directory; with --mount type=bind Docker errors out.
docker run --mount type=volume,src=pgdata,dst=/var/lib/postgresql/data postgres:16
docker run -v pgdata:/var/lib/postgresql/data postgres:16
More on Volumes & Bind Mounts
What are the three ways to persist or share data with a container?BeginnerVolume vs bind mount: when do you pick which?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