Score:1

How can I access my WSL2 docker volume data from other locations, such as a Ubuntu 20.04 distribution?

ng flag

I’ve installed Docker Desktop for Windows and a Ubuntu 20.04 distribution on my Windows 10 machine. I’ve been able to setup some containers and volumes. On my Win 10 machine, I can access this volume by using this in Windows Explorer

\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes

When I’m connected to my WSL2 Ubuntu distribution, I see under /mnt entries for all of my hard drives and one called wsl. However, when I browse to

/mnt/wsl/docker-desktop-data/version-pack-data

There is no “community” folder. How can I access this directory?

Indeed, how can I access this wsl share from a different machine than is running the wsl2 kernel?

NotTheDr01ds avatar
vn flag
What's your end goal in accessing those volumes from outside a container? There are probably a few options depending on your needs. Also, just a heads-up that `\\wsl$` under Windows is *not* the same as `/mnt/wsl` from inside WSL. `/mnt/wsl` is an ephemeral (tmpfs) directory set up to allow sharing between WSL instances. By "default", `/mnt/wsl` is empty when starting up WSL -- What you see in there is being created by Docker Desktop. Apparently Docker Desktop doesn't have a need to expose the volume data to other instances that way.
Score:0
cn flag

Had the same problem, found a solution somewhere on SO but I can't remember where, so here it is: in windows cmd execute similar to:

net use h: \\wsl$\docker-desktop-data

in WSL2 Ubuntu execute:

sudo mkdir /mnt/wsl2
sudo mount -t drvfs h: /mnt/wsl2

Now you should be able to access docker volumes using this mount.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.