Interview Prep/Docker/Volumes & Bind Mounts

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
All Docker questions Roadmap: Docker & containers

More on Volumes & Bind Mounts