>DevOps Interview KB

What's the actual difference between a Docker named volume and a bind mount, and when does choosing wrong cause a real problem?

BeginnerComparisonDocker6 min read

Short Answer

A bind mount maps a specific path on the host filesystem directly into the container — you control and know exactly where the data lives on the host, but the container's portability suffers, since it now depends on that exact host path existing with the right permissions. A named volume is managed entirely by Docker itself (stored in Docker's own managed area, typically /var/lib/docker/volumes/), portable across hosts running Docker without needing to know or care about the underlying host filesystem layout, but less directly inspectable/editable from the host side without going through Docker's own tooling.

Detailed Explanation

A bind mount is a direct host-path-to-container-path mapping: -v /home/user/data:/app/data mounts the exact host directory /home/user/data into the container at /app/data — any file on the host at that path is immediately visible in the container, and vice versa; this is exactly what local development workflows often want (editing code on the host, seeing changes reflected live in a running container), but it hardcodes a dependency on that specific host path existing.

A named volume is a Docker-managed storage location, abstracted from any specific host path: -v mydata:/app/data creates (or reuses) a volume named mydata, managed entirely by Docker — the actual host-side storage location is Docker's own concern, not something the container definition needs to know or reference directly, making the same container definition portable across different hosts without needing each host to have an identical directory structure.

The real problem from choosing bind mounts for production data: a container definition hardcoding a bind mount to a specific host path (/home/deploy/app-data) breaks the moment it's deployed to a different host with a different filesystem layout, or when multiple replicas of the same container need to run on different hosts (each would need the exact same path pre-existing and correctly populated) — this directly undermines container portability, which is one of containers' core value propositions in the first place.

The real problem from choosing named volumes for local development: a developer wanting to edit source code on their host machine and see changes reflected live inside a running container specifically needs the direct host-path visibility a bind mount provides — a named volume, being Docker-managed and not directly tied to a known host path, doesn't give this same live-editing convenience without extra steps.

Practical guidance: bind mounts fit local development (live code editing) and cases where you genuinely need the host's exact file layout accessible (mounting a specific configuration file from a known host location); named volumes fit production data persistence (databases, application state) where portability across hosts/environments matters more than knowing the exact underlying host path.

Interview Follow-Up Questions

  • How would you back up data stored in a named volume, given it isn't directly at a known host filesystem path the way a bind mount's data is?
  • What's a tmpfs mount, and when would you use it instead of either a named volume or a bind mount?
  • How does this distinction map onto Kubernetes' PersistentVolume model, given Kubernetes doesn't use Docker's exact same volume terminology?

Key Takeaways

  • A bind mount directly maps a specific host path into the container — precise host-path control, but reduced portability since that exact path must exist on wherever the container runs.
  • A named volume is managed entirely by Docker, abstracted from any specific host path — more portable across hosts, less directly host-path-visible.
  • Hardcoding a bind mount for production data breaks portability across hosts/replicas; using a named volume for local live-code-editing loses the direct host-path visibility that workflow needs.
  • Match the choice to the actual use case: bind mounts for local development/known-file-access needs, named volumes for portable production data persistence.

References

Last updated August 22, 2026 · Last reviewed August 22, 2026