23

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 
1

3 Answers 3

11

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

Sign up to request clarification or add additional context in comments.

Comments

6

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/

4 Comments

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).
Where did you read this? And the inspect option was already suggested by Fiber Optic, I will try it.
Your answer is wrong. If the external volume doesn't exist, an error is thrown
This answer may have been true for a legacy version of docker-compose but now should be deleted.
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.

5 Comments

Did you inspect it?
I`m getting an error trying to create external volume (ERROR: Volume data declared as external, but could not be found). stackoverflow.com/questions/47479767/…
As said in the 2nd post, create an external volume before trying to "link" it.
Inspect gives me a guest path - "Mountpoint": "/var/lib/docker/volumes/data/_data" but I dont see the host windows path there
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... :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.