Question

What is the difference between a Docker volume and a bind mount?

Vault Verified
Curated Intelligence
Definitive Source
Answer

Both make data survive a container being removed, and they differ in who manages the storage.

A bind mount maps a specific path on the host into the container. You control exactly where the data lives, and you can read and edit it with ordinary tools. This makes it ideal for development, where mounting your source directory means edits appear inside the container immediately without rebuilding.

A volume is managed by Docker in an area it controls. You refer to it by name rather than by path. Because Docker owns it, it works identically across operating systems, can be backed up and moved with Docker commands, and can use storage drivers for network or cloud storage.

The practical differences that matter:

  • Portability. A bind mount hardcodes a host path, so a compose file using one may not work on a colleague machine or on a server. A named volume works anywhere.
  • Permissions. Bind mounts carry host ownership into the container, which frequently causes permission errors when the container user differs from your host user. Volumes are initialised with the image directory ownership, which usually just works.
  • Performance. On Linux both are essentially native. On macOS and Windows, where containers run in a virtual machine, bind mounts cross a filesystem boundary and can be dramatically slower for workloads with many small file operations, such as installing dependencies. This surprises people moving between platforms.
  • Initial contents. A new volume mounted over a non-empty image directory is populated from that directory. A bind mount hides whatever was there.

The common convention is bind mounts for source code in development, and named volumes for databases and anything the application writes.

Related Questions