Upon inspect my docker container info shows:
"HostConfig": {
"Binds": [
"/opt/myconfig:/run/db_config:rw"
],
I suspect this works as a mounting volumes with:
-v mysql-data:/var/lib/mysql
But, I need to understand the difference between -v and whatever cmd created the Binds. Which cmd as -v could create the Binds entry?
The -v
option on docker run
can map both a docker volume or a host directory.
If the thing you're mapping is a directory or a file, docker creates a bind mount. If it's not, then docker creates a volume mapping.
For example,
docker run -v ./data:/data myimage
creates a bind mount, whereas
docker run -v data:/data myimage
creates a volume mount.
You can also be more explicit by using the --mount
option instead. Using --mount
is recommended, but as it's more verbose, most people use the -v
option.
In your example, what created the bind mount would be an option like this
-v /opt/myconfig:/run/db_config
Mounts are read/write per default, so there's no reason to specify that.
You can read more here.