Interview Q&A / Docker & Kubernetes

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is the difference between the -v and --mount flags in Docker?

SHORT ANSWER

Both attach storage. -v is a compact colon-separated string, while --mount uses explicit key=value pairs. --mount is clearer and errors if a bind path is missing, while -v silently creates the host folder.

Explain it simply

-v is shorthand like writing 'Aman - 9 - B' on a slip. --mount is the full form with labels: name, roll number, section. Same information, harder to misread.

-v data:/app/data:ro packs source, destination and options into one string, and the meaning of the first part depends on its shape: a path means bind mount, a bare name means named volume. --mount type=volume,source=data,target=/app/data,readonly spells out everything. A key behavioural difference: with -v /host/path:/app and a missing host path, Docker creates an empty directory, often owned by root, which hides typos. With --mount type=bind, a missing source path produces an error.

Both work in Compose (short and long syntax). Docker documentation recommends --mount for new work because it is explicit.

Example

bash
docker run -v data:/app/data:ro myapp
docker run --mount type=volume,source=data,target=/app/data,readonly myapp
docker run --mount type=bind,source="$(pwd)",target=/app myapp

What to say in the interview

"-v is the short form and --mount is the explicit key=value form. --mount fails when a bind source is missing, while -v creates the folder silently, so I use --mount when clarity matters."

Common mistakes

  • Mistyping a host path with -v and getting an empty auto-created folder.

#docker#volumes#mount

Related questions

Practise more Docker & Kubernetes questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Docker & Kubernetes quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.