Types
| Type | Syntax | Managed by | Use for |
|---|---|---|---|
| Bind mount | /host/path:/container/path | You | Dev, config, temp files |
| Volume mount | volume-name:/container/path | Docker | Production, databases |
| tmpfs | --tmpfs /tmp | RAM | Ephemeral scratch space |
Bind mount
Direct mapping — container and host share the exact same files, two-way in real time.
docker run -v /host/path:/container/path myimageGood for development (live code updates). Security risk: container can modify/delete host files.
Volume mount
Docker manages storage (typically /var/lib/docker/volumes/). More isolated, portable across hosts.
docker run -v my-volume:/container/path myimageUse docker volume inspect <name> to find the actual host path.