Rancher Convoy - Subtle 'volume_driver' nuance - beware leading '/' on 'volume' assignments

I have discovered that if you create docker-compose file with volume and volume_driver attributes, that the volume_driver assignment is ignored if your volume assignment has a leading ‘/’ (slash) when you pass it to rancher_compose application - eg /vol1:/vol1 creates volume on Docker local storage, but vol1:/vol1 creates volume on convoy storage.

I hope this saves someone the few hours I have spent tracking this nuance down… BTW, this is not a Rancher nuance, same thing happens if you issue the ‘run’ commands directly to Docker.

Thanks for sharing @gesrat.

Here’s a brief explanation as to why it behaves that way: If you lead with a slash, that tells docker that you want a host bind mount. For example, if you had -v /tmp:/inthecontainer/tmp, that tells docker that you want to bind mount the host’s /tmp directory into the container at /inthecontainer/tmp.

Not leading with a slash is a new function of the docker api/cli that was introduce with the rest of the volume API. That tells docker (and rancher) that you want a named volume instead of host bind mount.