Docker compose external volume path

I found out that external volume is just a volume that has been created outside of Docker Compose and it is still located inside docker's vm:

C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx in my case.

For sharing data between my host and the containers I can define standard volumes inside the compose services and specify my preferred host directory there, or use local persist plugin

("Create named local volumes that persist in the location(s) you want").


Using external makes docker search for a folder named what you called it - in your case mydata.

If this folder doesn't exist there will be no mount and no error will be raised.

https://docs.docker.com/compose/compose-file/compose-file-v3/#external

You can also use the inspect to see the exact location:

Docker inspect -f "{{json. Mounts}}" container_name | jq.

https://container-solutions.com/understanding-volumes-docker/