8

I'm both new to Ubuntu and Docker. I cut to the chase, when I create a volume using the sudo docker volume create TEST command, where should I expect to find the TEST volume and its data in my hard drive?

If I want it to be located in another drive, lets say D:\ (still new to ubuntu not sure if it also applies to linux) drive, what do I have to do?

Transcendent
  • 265
  • 2
  • 3
  • 8

4 Answers4

13

Looks like it is /var/lib/docker/volumes

Here's what I got:

$ docker volume create TEST 
$ ls /var/lib/docker/volumes
metadata.db  TEST/
theferrit32
  • 551
  • 4
  • 9
3

Use docker volume inspect TEST (docs), and there will be a key "Mountpoint" with the path to it:

$ docker volume inspect TEST
[
    {
        "CreatedAt": "2020-09-18T10:46:55-07:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/TEST/_data",
        "Name": "TEST",
        "Options": {},
        "Scope": "local"
    }
]

To extract just the path, for example to use in a script:

$ docker volume inspect --format '{{ .Mountpoint }}' TEST
/var/lib/docker/volumes/TEST/_data
  • Thanks, this is an old question, I already solved it a long long time ago back in the day I was new to docker. But thank you anyway :) – Transcendent Sep 19 '20 at 17:12
1

On Ubuntu installations that use snap for installing docker the path is:

/var/snap/docker/common/var-lib-docker/volumes/

For 20.04 LTS snap is default.

0

If you're working on WSL2 through Docker Desktop for Windows, volumes will be found here:

/var/data/docker-desktop/default/daemon-data

If you are working on actual Ubuntu, then yes, as the above answer said it will be located in

/var/lib/docker/volumes

pants
  • 1
  • 1