1

All I want to is accessing docker volume's Mountpoint in terminal.

PS C:\> docker volume create myvol
myvol
PS C:\> docker volume inspect myvol
[
    {
        "CreatedAt": "2019-12-04T13:41:02Z",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/myvol/_data",
        "Name": "myvol",
        "Options": {},
        "Scope": "local"
    }
]

Now I want to access to Mountpoint path /var/lib/docker/volumes/myvol/_data.

PS C:\> docker-machine ssh default
docker@default:~$ cd /var/lib/docker
docker@default:/var/lib/docker$ sudo su
root@default:/mnt/sda1/var/lib/docker# cd volumes
root@default:/mnt/sda1/var/lib/docker/volumes# ls -al
total 32
drwx------    2 root     root          4096 Dec  4 13:25 .
drwx--x--x   15 root     root          4096 Dec  4 13:27 ..
-rw-------    1 root     root         32768 Dec  4 13:27 metadata.db

It seems Mountpoint path doesn't exist. So I thought it is because the volume is empty, so I tried again after generate some files on that volume, However the result is same - There is no myvol directory in /var/lib/docker/volumes. Is it normal? Even if the dir doesn't exist I can store data permanently with this volume. Is it normal behavior or something I missed?

ton1
  • 7,238
  • 18
  • 71
  • 126
  • Hi Juntae, have you mounted the volume to your container? not sure about docker-machine, but with docker you would run something like `docker run -v myvol:/path/to/mount myimage` – ckaserer Dec 04 '19 at 14:09
  • `/var/lib/docker/volumes/myvol/_data` is the location of the volume data on your host machine – ckaserer Dec 04 '19 at 14:10
  • @ClemensKaserer Yes, I created some files to the volume. And it is host machine. it's not bind mounts but data volume. – ton1 Dec 04 '19 at 14:27
  • You shouldn’t be trying to directly access that `/var/lib/docker` subdirectory at all. If accessing the files from your host is important, a bind mount is a better choice than a named volume. – David Maze Dec 04 '19 at 14:37

1 Answers1

0

Your question is answered here: https://stackoverflow.com/a/64418064/8074003

I could find in \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\ several directories, one directory for each one of the data volumes.

Also is posible to be found in \\wsl$\docker-desktop-data\data\docker\volumes it depends on the docker engine version.