Choosing between `--mount` and `-v`.
BeginnerScenarioVolumes, storage and data
Answer
Situation read → Both attach storage.
What I'd do → Prefer --mount type=volume,src=data,dst=/data,readonly: explicit key-value syntax, and it errors if a bind source path does not exist, whereas -v silently creates a root-owned directory.
Why → Fewer surprises and clearer reviews.
Interview tip → Compose long syntax mirrors --mount.
More on Volumes, storage and data
A Postgres container was removed and the data is gone. How should it have been run?BeginnerBind mount or named volume for local development of a Node app?BeginnerHow do you back up a named volume?IntermediateTwo containers must share files. What are your options?BeginnerA container needs a writable temp area but the root filesystem is read-only.IntermediateMoving a database volume from one Docker host to another.Intermediate