Bind mount
File or directory on host mounted into container. You refer to this file/directory using the full file path used on the host.
The problem with a bind mount is you have to have the full host file path which may be different on different hosts. E.g. if you use /Users/dave
it’s going to break if someone else doesn’t have a Users/dave
directory.
Volume
While bind mounts are dependent on the directory structure of the host machine, volumes are completely managed by Docker. They’re created in /var/lib/docker/volumes
and you refer to them by name. E.g.
-v mysql_data:/containerdir
Here’s what this means:
- the first field is the name of the volume. It’s unique on a given host machine
- the second field is the path where the file or directory are mounted in the container
https://docs.docker.com/storage/bind-mounts/
https://docs.docker.com/storage/volumes/#choose-the–v-or—mount-flag
https://stackoverflow.com/questions/47150829/what-is-the-difference-between-binding-mounts-and-volumes-while-handling-persist