19

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 
ramiwi
  • 902
  • 2
  • 10
  • 28

3 Answers3

9

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

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
ramiwi
  • 902
  • 2
  • 10
  • 28
7

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/

smac89
  • 39,374
  • 15
  • 132
  • 179
Yonah Dissen
  • 1,197
  • 1
  • 8
  • 16
  • 2
    The docs (linked) says mydata is a volume name, not a file name, and external volumes does not have a path configuration key (to point to a target directory). – ramiwi Nov 23 '17 at 10:19
  • Where did you read this? And the inspect option was already suggested by Fiber Optic, I will try it. – ramiwi Nov 23 '17 at 12:45
  • 1
    Your answer is wrong. If the external volume doesn't exist, an error is thrown – smac89 Feb 17 '22 at 21:36
0

If you mean the internal path used by Docker, try to inspect an existing one:

docker volume inspect my-vol.

It will show where the data is stored.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Fiber Optic
  • 184
  • 5
  • Did you inspect it? – Fiber Optic Nov 23 '17 at 08:25
  • I`m getting an error trying to create external volume (ERROR: Volume data declared as external, but could not be found). https://stackoverflow.com/questions/47479767/docker-compose-volume-declared-as-external-but-could-not-be-found – ramiwi Nov 24 '17 at 20:45
  • As said in the 2nd post, create an external volume before trying to "link" it. – Fiber Optic Nov 24 '17 at 20:54
  • Inspect gives me a guest path - "Mountpoint": "/var/lib/docker/volumes/data/_data" but I dont see the host windows path there – ramiwi Nov 24 '17 at 21:09
  • It works for me fine, with the data named volume: docker volume inspect data `[ { "CreatedAt": "2020-05-27T08:38:01Z", "Driver": "local", "Labels": {}, "Mountpoint": "/var/lib/docker/volumes/data/_data", "Name": "data", "Options": null, "Scope": "local" } ]` There is a /var/lib/docker/volumes/metadata.db, which should contain the further information... :-) – szabozoltan May 27 '20 at 08:43