work monitored
work monitored

Reputation: 451

Docker volume details for Windows

I am learning docker and deploying some sample images from the docker hub. One of them requires postgresql. When I deploy without specifying a volume, it works beautifully. When I specify the volume 'path on host', it fails with inability to fsync properly. My question is when I inspect the volumes, I cannot find where docker is storing those volumes. I'd like to be able to specify a volume so I can move the data if/when needed. Where does Docker store this on a windows machine? I tried enabling volume through Kinematic but the container became unusable.

> docker volume inspect 0622ff3e0de10e2159fa4fe6b7cd7407c6149067f138b72380a5bbe337df8f62
[
    {
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/0622ff3e0de10e2159fa4fe6b7cd7407c6149067f138b72380a5bbe337df8f62/_data",
        "Name": "0622ff3e0de10e2159fa4fe6b7cd7407c6149067f138b72380a5bbe337df8f62",
        "Options": {},
        "Scope": "local"
    }
]

I can create a volume through docker but am not sure where it is stored on the harddisk.

Upvotes: 1

Views: 1015

Answers (1)

NeeL
NeeL

Reputation: 720

If you're on windows 10 and use Docker For Windows, docker will create a VM and run it on your local hyper-v, the volumes you create are then located inside of this VM which is stored in something called MobyLinuxVM.vhdx (you can check it in the settings of docker).

One way to have your data on your host computer for now is to share a drive on docker settings and then map your postgres data folder to your windows hard drive. Something like docker run -it -v /c/mypgdata:/var/lib/postgresql/data postgres

Another way would be to create a volume with a specific driver, take a look at existing volume drivers if one can do what you want. This one could be of interest for you : https://github.com/CWSpear/local-persist

You can also enter the MobyLinux VM with this "kind of" hack

#get a privileged container with access to Docker daemon
docker run --privileged -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker alpine sh

#run a container with full root access to MobyLinuxVM and no seccomp profile (so you can mount stuff)
docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host alpine /bin/sh

#switch to host FS
chroot /host

#and then go to the volume you asked for
cd /var/lib/docker/volumes/0622ff3e0de10e2159fa4fe6b7cd7407c6149067f138b72380a5bbe337df8f62/_data

Found here : http://docker-saigon.github.io/post/Docker-Beta/

Upvotes: 4

Related Questions