Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access the volume in host in docker for windows

I run the docker for Windows and ubuntu in WSL. When I run the following command

docker volume create test
docker volume inspect test

I get the following output

[
    {
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/test/_data",
        "Name": "test",
        "Options": {},
        "Scope": "local"
    }
]

when I access the location, I get bash: cd: /var/lib/docker/volumes: No such file or directory

So how should I access the folder?

like image 961
asuka Avatar asked Jan 19 '26 04:01

asuka


1 Answers

The directory is is protected so you can cd into it, however you can ls the contents:

sudo ls /wsl/docker-desktop-data/data/docker/volumes/test/_data

I've modified my WSL set up as per this article so you may find your path is different. I think the default path is probably /mnt/wsl/docker-desktop-data/data/docker/volumes/test/_data

You might find it more useful to mount a directory in your Windows user folder which can be done by changing the WSL mount point as per the article linked to above and then running:

docker volume create --driver local --name test --opt device=/run/desktop/mnt/host/c/Users/<username>/test --opt type=none --opt o=bind

(assuming you've got a folder called test at the root of your Windows user directory)

like image 99
Nick Graham Avatar answered Jan 22 '26 02:01

Nick Graham