aerioeus
aerioeus

Reputation: 1410

Where are the Docker volumes I have created stored on a windows machine?

I understand data Volumes will be local to the Linux VM running on Windows and not be available on the Windows host. You can use them with other containers, but not from the host. However I’m wondering if one can locate them anyway. when I check in the windows linux subsystem for volumes created i get:

[
  {
    "CreatedAt": "2018-08-08T09:41:56Z",
    "Driver": "local",
    "Labels": {},
    "Mountpoint": "/var/lib/docker/volumes/my-vol/_data",
    "Name": "my-vol",
    "Options": {},
    "Scope": "local"
  }
]

But there is obviously no docker dir on the WSL. is it possible to access the HyperV istance linux where the docker stuff happens sowehow to check the directory there?

merci a

Upvotes: 1

Views: 2119

Answers (1)

aerioeus
aerioeus

Reputation: 1410

On Windows, Docker runs in a VM called MobyLinuxVM, but you cannot login to that VM via Hyper-V Manager. We aren’t technically going to SSH into the VM, we’ll create a container that has full root access and then access the file system from there.

  • Get container with access to Docker Daemon
  • Run container with full root access
  • Switch to host file system
  • Open a Command prompt and execute the following:

    $ docker run --privileged -it -v /var/run/docker.sock:/var/run/docker.sock 
    jongallant/ubuntu-docker-client 
    $  docker run --net=host --ipc=host --uts=host --pid=host -it --security- 
    opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh
    $  chroot /host
    

then

/ # cd var
/var # cd lib
/var/lib # ls
cni  containerd  docker  kubeadm  kubelet-plugins  log  lost+found  nfs  swap
/var/lib # cd docker
/var/lib/docker # ls
builder  buildkit  containerd  containers  image  network  overlay2  plugins  runtimes  swarm  tmp  trust  volumes
/var/lib/docker # cd volumes
/var/lib/docker/volumes # ls
my-vol
/var/lib/docker/volumes # 

Upvotes: 2

Related Questions