Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose external volume path

Where is the mount point of an external volume located on a windows 10 host machine when using docker compose v3? e.g. The host path for mydata when the top-level volumes key is set as follows:

volumes:
  mydata:
    external: true 
like image 552
ramiwi Avatar asked Nov 22 '17 21:11

ramiwi


2 Answers

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").

like image 82
ramiwi Avatar answered Sep 22 '22 08:09

ramiwi


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/

like image 43
Yonah Dissen Avatar answered Sep 18 '22 08:09

Yonah Dissen