55

I am running Windows Subsystem Linux (WSL) with Ubuntu as client OS under Windows 10. Now I installed Docker Desktop on the Windows host and enabled the WSL integration in the Docker settings. That works fine so far, I can access the Docker daemon running on the Windows host from my WSL Ubuntu client.

Now I am wondering where all the Docker volumes and other data is stored in this setup. Usually these are under /var/lib/docker, but it seems when using WSL this is not the case. When running df -h I can see the following Docker-related lines:

/dev/sdd        251G  3.1G  236G   2% /mnt/wsl/docker-desktop-data/isocache
/dev/sdc        251G  120M  239G   1% /mnt/wsl/docker-desktop/shared-sockets
/dev/loop0      244M  244M     0 100% /mnt/wsl/docker-desktop/cli-tools

So they are somewhere on the Windows host it seems.
... but where?

questionto42
  • 7,175
  • 4
  • 57
  • 90
Matthias
  • 9,817
  • 14
  • 66
  • 125

14 Answers14

115

When I create a volume named shared_data in docker, I can find it under

\\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\shared_data\\_data
msanford
  • 11,803
  • 11
  • 66
  • 93
Piero
  • 1,638
  • 1
  • 13
  • 14
  • Yes, that's the path if you use Docker Desktop on WSL2 (Ubuntu), see : https://stackoverflow.com/a/64418064/6075581 – Connected Wanderer Oct 22 '20 at 19:43
  • Search for this path in windows explorer when docker engine is active – GRANZER Nov 24 '21 at 16:10
  • Can we assume that the standard WSL warning of not editing WSL files through Windows File Explorer still holds for Docker containers? – j08691 Feb 16 '22 at 20:02
  • Note, this is not the same path as /mnt/wsl ... inside WSL, this is only the path as accessed from the Windows 'host' file system – mozboz May 27 '22 at 09:12
  • In Docker Desktop version 4.13 its at "\\wsl.localhost\docker-desktop-data\mnt\wsl\docker-desktop-data\version-pack-data\community\docker\volumes" – DinushaMadusanka Mar 04 '23 at 04:20
49

You can find WSL2 volumes under a hidden network share. Open Windows Explorer, and type \\wsl$ into the location bar. Hit enter, and it should display your WSL volumes, including the ones for Docker for Windows.

Rohaq
  • 1,886
  • 1
  • 15
  • 22
  • 9
    To follow onRohaq's answer...paste this into Windows Explorer to see the data volumes: \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes PS. I am no Docker expert but this tip helped me greatly. – rr789 Dec 08 '20 at 03:16
  • All I get inside that volumes folder is two files, `backingFsBlockDev` and `metadata.db` – Matt Fletcher May 21 '23 at 13:21
  • @MattFletcher What path are you using? – Rohaq May 28 '23 at 00:07
17

If you are wondering where on the Windows host the docker volumes are located, for me they seem to be at:

C:\Users\username\AppData\Local\Docker\wsl\data\ext4.vhdx

and

C:\Users\username\AppData\Local\Docker\wsl\distro\ext4.vhdx

presumably, these are docker-desktop-data and docker-desktop respectively.

In theory, these WSL2 instances can be re-located to an alternate drive to free disk space as per this post; that is the standard method for exporting, unregistering, and re-importing an instance from a new location. This process is also described here (with regard to standard WSL instances).

(Caveat - I haven't yet done this with the docker WSL2 instances yet myself, only for Ubuntu using the method in the second link.)

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Carl Higgs
  • 301
  • 2
  • 7
15

Windows 10 + WSL2

I run docker-desktop on Windows 10 + WSL2. Just make sure you run the docker desktop, so the path would be accessible from a network.

I found my volume data under

\\wsl$\docker-desktop-data\data\docker\volumes

enter image description here

Note that you need to have docker desktop running before you will be able to discover those network direcotories:

enter image description here

DevWL
  • 17,345
  • 6
  • 90
  • 86
10

Most answers on this topic are about the location from the Windows side, I needed to access the container log files (the issue is the same as for volumes) from my WSL distribution, the Windows path \\wsl$ was not an option.

The files could be found on Windows in \\wsl$\docker-desktop-data\version-pack-data\community\docker\containers.
From the WSL distribution, I could go to /mnt/wsl/docker-desktop-data/version-pack-data but it was empty.

Finally found a solution here:

  1. From Windows, create a disk for docker-desktop-data:
net use w: \\wsl$\docker-desktop-data
  1. From your WSL distribution, mount it to docker:
sudo mkdir /mnt/docker
sudo mount -t drvfs w: /mnt/docker

Now you can get everything you want, in my case log files:

ls -l /mnt/docker/version-pack-data/community/docker/containers/

total 0
drwxrwxrwx 4 root root 512 May 19 15:06 3f41ade0891c06725e828853524d73f185b415d035262f9c51d6b6e03654d505

AymDev
  • 6,626
  • 4
  • 29
  • 52
  • If someone is looking for the volumes, these would then be located under /mnt/docker/data/docker/volumes – Maxi Apr 12 '23 at 21:19
7

Docker Desktop's WSL2 feature creates two new wsl2 containers docker-desktop and docker-desktop-data, which can be seen by the command wsl -l -v

NAME                   STATE           VERSION
* Ubuntu-18.04           Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2

This is where the docker daemon actually runs and where you can find the data you are looking for.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
danielorn
  • 5,254
  • 1
  • 18
  • 31
5

The volumes in the wsl2 kernel are mapped as follows:

docker run -ti -v host_dir:/app amazing-container will get mapped to /mnt/wsl/docker-desktop-data/data/docker/volumes/host_dir/_data/

The above is the right path, even though docker volume inspect amazing-container will tell you differently (/var/lib/docker/volumes/).

To conclude, the volumes are mapped to: /mnt/wsl/docker-desktop-data/data/docker/volumes/

0x90
  • 39,472
  • 36
  • 165
  • 245
  • How can you query the docker server to return the right path? – Carl in 't Veld Jan 11 '21 at 13:40
  • @Carlin'tVeld replace `/var/lib/docker/volumes/` with `/mnt/wsl/docker-desktop-data/data/docker/volumes/` – 0x90 Jan 11 '21 at 13:44
  • 5
    Well I would like to learn how to pull that data from the Docker server. In the meanwhile I found out that at my side the path is different: \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\myvol\_data. Refer to https://github.com/microsoft/WSL/discussions/4176. Strangely when trying to reach out to his folder within wsl2 I find /mnt/wsl/docker-desktop-data/version-pack-data being empty. – Carl in 't Veld Jan 11 '21 at 15:49
  • 1
    @Carlin'tVeld Same for me, I posted an [answer](https://stackoverflow.com/questions/61083772/where-are-docker-volumes-located-when-running-wsl-using-docker-desktop#answer-72307042) with a solution found in the GitHub discussion. – AymDev May 19 '22 at 15:19
  • 1
    Why would the wsl developers point the mount path to a different location than what `docker volume inspect` outputs? Horrible. – j7skov Jul 26 '22 at 13:42
  • 1
    @j7skov maybe for persistence and consolidation of how docker runs inside wsl and in windows – 0x90 Jul 26 '22 at 14:01
3

In my case, i install docker-desktop on wsl2, windows 10 home. i find my image files in

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

All image files are stored there, and have been seperated into several folders with long string names. When i look into every folder, i can find all the real image files in "diff" folders.
Although the terminal show the path "var/lib/docker", but the folder doesn't exsit and the actual files are not stored there. i think there is no error, the "var/lib/docker" is just linked or mapped to the real folder, kind like that. In windows, we also use mklink to link two folders, it is similar, right?

Json Bourne
  • 139
  • 1
  • 1
  • Indeed, this is correct. The physical images and their layers are organized in this folder. But please note that they work together with /volumes folder as well. – Mário Meyrelles May 17 '21 at 19:58
2

You can find volumes and others data when using docker with WSL under docker-desktop-data

volume and other data in docker

Babir
  • 29
  • 3
  • 1
    Mine didn't have host, but everything else is the same on my system. Once you get to the docker directory permissions are locked down. I did a `sudo ls volumes` to finally see my data – Ben Ogorek Aug 21 '20 at 15:46
2

If you are running Docker on Windows host, using Docker Desktop, you can access the volumes at \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\ (search this path from windows explorer and make sure docker engine is running).

When running Docker desktop app, the app creates its own Linux VM or using WSL to run the docker container and the path /var/lib/docker/volumes/ is from within that VM I think. The volumes are created as mountable .vhdx file at

C:\Users\username\AppData\Local\Docker\wsl\distro\

but accessing this directly is tricky.

Ref: Google how to access WSl files from Windows

GRANZER
  • 355
  • 3
  • 13
1

Windows 10 + WSL2, Docker Desktop v4.13.1, free service tier, 2022-11-03: I found my volumes at \\wsl$\docker-desktop-data\data\docker\volumes

ToddZ
  • 11
  • 2
0

Windows 11 + WSL2

\wsl.localhost\docker-desktop-data\data\docker\volumes\mivolumen

hfeest
  • 1
  • 1
0

On Windows 11 and WSL2 (Ubuntu 22.04.2) the path shown in File Explorer is:

\\\wsl.localhost\docker-desktop-data\data\docker\volumes\my-volume\_data

You can browse to it by first typing in \\\wsl$ or \\\wsl.localhost on the search prompt.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
shubh
  • 21
  • 2
0

I'll leave this here for other people looking for the path on the Linux distro used on WSL (Windows 11, Docker Desktop 4.20.1).

Given the Windows path: \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes (or \\wsl.localhost\docker-desktop-data\version-pack-data\community\docker\volumes)

It'll be found on the following path on the distro: /mnt/wsl/docker-desktop-data/version-pack-data/community/docker/volumes (requires sudo)

Aruku
  • 11
  • 5