24
  1. Installed docker desktop for windows 10
  2. Used powershell to run docker containers ( ubuntu )
  3. Now, I want to browse to /var/lib/docker --> want to browse to overlay2 to check layers.. /diff folder etc.
  4. If i access /var/lib/docker folder - powershell complains that this folder does not exist.

Other piece of info: I have already checked out the disk image location which is mapped for docker desktop. It is a vhdx file. I was not able to open it with Oracle virtual box - it says it is not a supported version file. I tried opening in Hyper V manager, the VM is getting listed: DockerDesktopVM.

  • But my objective is to do SSH and browse /var/lib/docker folders..
a3.14_Infinity
  • 5,653
  • 7
  • 42
  • 66
  • i also had same question and didnt find a direct answer. Did you happen to find where the volumes are located ? – Nag Mar 24 '20 at 09:02
  • no, i haven't found yet – a3.14_Infinity Mar 24 '20 at 09:59
  • I am unable to find a way to browse the docker volumes from within the wsl2 but from the outside (windows explorer) you can check this path: \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes – xYan Nov 17 '21 at 12:11
  • \\wsl.localhost\docker-desktop-data\data – hoomi Nov 19 '22 at 11:14

4 Answers4

14

(This is for case of WSL2. It is my answer to a similar question)

Docker images are managed by docker's own VM. The path /var/lib/docker given by "docker info" is relative to docker's host file system, not your container's file system. The mount points are different for them. You can view docker's host file system in either of the following ways:

  1. You can mount the host file system to a container directory. Such as,

    docker run -v /:/data -it ubuntu /bin/bash

    This command runs a shell in Ubuntu docker image, mounting docker's file system to /data directory. There you can find a complete file system under /data, including the ./var/lib/docker. If you want, you can "chroot /data" in the shell prompt to have a better view.

  2. When docker is enabled with your distribution in WSL2, you can always check your containers in your distribution /mnt directory. Docker has mounted everything for you.

    /mnt/wsl/docker-desktop-data/data/docker
  3. If you are seasoned enough, you may find the actual location of the virtual disk of all the data in your Windows directory.

    C:\Users\your_name\AppData\Local\Docker\wsl\data\

    Or probably just for fun:

    \\wsl$\Ubuntu\mnt\wsl\docker-desktop-data\data\docker

    Unfortunately I haven't tried to dive into them.

Xiao-Feng Li
  • 680
  • 7
  • 12
  • in your method 2, /mnt/wsl/docker-desktop-data/data/docker this folder is not there. But I found it here: /mnt/host/wsl/docker-desktop-data/data/ , but the folder is empty. – user139301 Feb 19 '21 at 01:56
  • @user139301 Yes, "docker desktop" no longer shows the same data as it did in earlier versions. Apparently the newer version (at least the current v3.8.1 I am using) seems give you less control than before. – Xiao-Feng Li Feb 19 '21 at 18:25
  • For me (with WSL2), steps 1-2 worked perfectly but neither of the suggested locations in step 3 did - in both cases the `data` folder was present but didn't have the data in it. – Steve Chambers Apr 23 '21 at 12:41
  • Can u please elaborate on "Docker images are managed by docker's own VM." – Shivani Aug 18 '21 at 07:58
  • Methods 1 & 2 don't work. I can access /var/lib but there isn't a docker folder underneath. I can however find the \\wsl$\..... path. I was hoping to access the volume mountpoint from the Docker host file system instead of from Windows though. – shadowz1337 Jul 05 '22 at 06:30
8

As stated on This page of docker forums you can run plain debian docker image with shell and change it's namespace to docker host.

The terminal command you need to run is:

>> docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -i sh

as I understand after running debian image as terminal (-it option), you need to call command nsenter with specified parameters to change namespace to host machine. After this your container becomes Docker host and you can view all it's files.

after this command you can access docker images simply by calling:

>> cd ls /var/lib/docker/
Rezga
  • 390
  • 1
  • 10
3

In the left pane of your windows file explorer, you can find all you computer drives. If you have installed WSL (when you setup your Docker), you will see this Linux pinguin icon.

Select the docker-desktop-data directory and inside it, the data directory. Within the data directory you will find there the docker directory and the volume generated by docker run ... -v command.

shortcut would be: cd \\wsl.localhost\docker-desktop-data\data

hoomi
  • 99
  • 1
  • 4
0

In Windows,

Open Docker Desktop, then got to Settings, Resources, Advanced, and look at Disk image location. If you go to the location you will found VHDX files. Those files are automaticaly mounted by Windows (Docker Desktop) and are easily readable on the left panel of Windows Explorer.

The path :

\\wsl.localhost\

In my case I was looking for those files beacause I wanted to install all my Docker Containers on USB device.

florian
  • 21
  • 3