like many others, I found this thread from Google search. I do not understand what the confusion here is. Its pretty simple, as described by the OP
Many docker-compose.yml for pre-existing third-party projects include the usage of “docker volumes”, as opposed to a normal bind mount.
example;
By default it seems that Docker volumes are stored under /var/lib/docker/volumes
Frankly, this seems like a mistake in the first place, for the reasons described by OP; many users on managed systems do not have write access under /var
. Similarly, if you do manage your own server, your OS boot disk that hosts /var
is likely not appropriate for high-throughput usage that a Docker Volume is supposedly “ideal” for. AFAICT, its extremely common for a server boot-disk to be a mid-grade mid-capacity SSD, meanwhile all the real “work” on the system is meant to happen on higher capacity NVMe disks meant explicitly for high throughput IO. So naturally, you would want to host you “docker volumes” on the high capacity NVMe disks.
This is exactly what OP is asking for, I think.
Thanks for this, but I am still a little confused by what is being described here.
if I am reading this correctly, this part;
--opt device=/data/volumes/testvol testvol
is creating a docker volume named “testvol” and storing the data for it on the host disk location /data/volumes/testvol
Is the docker volume created this way going to still be the “normal” style of docker volume? Or is it instead creating a bind mount to a directory on the host disk?
The Mounpoint will always be in /var/lib/docker/volumes/{volume name}/_data
I am confused by this statement, are you suggesting that the location of “testvol” inside the container will be at /var/lib/docker/volumes/testvol/_data
? Or are you referring to the host system?
Finally, how are you supposed to configure all of this from within your docker-compose.yml
? It seems like the entire point of using docker compose in the first place, is to avoid having to run all these arbitrary one-off commands in the terminal and to have the entire docker config for your project in a scripted and reproducible configuration. In particular it seems like you would likely want your docker volume located in the same directory as your docker-compose.yml, or at least have some pre-defined common location on the host for your projects’ volumes