Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access /var/lib/docker in windows 10 docker desktop?

  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..
like image 417
a3.14_Infinity Avatar asked Feb 26 '20 07:02

a3.14_Infinity


People also ask

Where is var lib docker containers on Windows?

Debian: /var/lib/docker/ Windows: C:\ProgramData\DockerDesktop. MacOS: ~/Library/Containers/com.

How do I find the var folder in Windows?

In a File Browser you can gain access to these files by opening the folders with a file browser with elevated privileges. (for read/write access) Try Alt+F2 and gksudo nautilus , then hit Ctrl+L and write /var/www and hit Enter in order to be directed to the folder.

Where are images stored in docker for Windows?

In a default installation, layers are stored in C:\ProgramData\docker and split across the "image" and "windowsfilter" directories. You can change where the layers are stored using the docker-root configuration, as demonstrated in the Docker Engine on Windows documentation. Only NTFS is supported for layer storage.


Video Answer


2 Answers

(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.

like image 158
Xiao-Feng Li Avatar answered Oct 18 '22 20:10

Xiao-Feng Li


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/
like image 8
Rezga Avatar answered Oct 18 '22 22:10

Rezga