Locating data volumes in Docker Desktop (Windows)
Solution 1
Your volume directory is /var/lib/docker/volumes/blog_postgres-data/_data
, and /var/lib/docker
usually mounted in C:\Users\Public\Documents\Hyper-V\Virtual hard disks
. Anyway you can check it out by looking in Docker settings.
You can refer to these docs for info on how to share drives with Docker on Windows.
BTW, Source
is the location on the host and Destination
is the location inside the container in the following output:
"Mounts": [
{
"Name": "fac362...80535",
"Source": "/var/lib/docker/volumes/fac362...80535/_data",
"Destination": "/webapp",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
]
Updated to answer questions in the comment:
My main curiosity here is that sharing images etc is great but how do I share my data?
Actually volume
is designed for this purpose (manage data in Docker container). The data in a volume is persisted on the host FS and isolated from the life-cycle of a Docker container/image. You can share your data in a volume by:
-
Mount Docker volume to host and reuse it
docker run -v /path/on/host:/path/inside/container image
Then all your data will persist in
/path/on/host
; you could back it up, copy it to another machine, and re-run your container with the same volume. -
Create and mount a data container.
Create a data container:
docker create -v /dbdata --name dbstore training/postgres /bin/true
Run other containers based on this container using
--volumes-from
:docker run -d --volumes-from dbstore --name db1 training/postgres
, then all data generated bydb1
will persist in the volume of containerdbstore
.
For more information you could refer to the official Docker volumes docs.
Simply speaking, volumes
is just a directory on your host with all your container data, so you could use any method you used before to backup/share your data.
can I push a volume to docker-hub like I do with images?
No. A Docker image is something you can push to a Docker hub (a.k.a. 'registry'); but data is not. You could backup/persist/share your data with any method you like, but pushing data to a Docker registry to share it does not make any sense.
can I make backups etc?
Yes, as posted above :-)
Solution 2
I am Windows + WSL 2 (Ubuntu 18.04).
Type in the Windows file explorer :
- For Docker Engine v20.10.16:
\\wsl$\docker-desktop-data\data\docker\volumes
- For Docker Engine v19.03:
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\
You will have one directory per volume.
Solution 3
For Windows 10 + WSL 2 (Ubuntu 20.04), Docker version 20.10.2, build 2291f61
Docker artifacts can be found in
DOCKER_ARTIFACTS == \\wsl$\docker-desktop-data\version-pack-data\community\docker
Data volumes can be found in
DOCKER_ARTIFACTS\volumes\[VOLUME_ID]\_data
Solution 4
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\
Worked for me as well (Windows 10 Home), great stuff.
Solution 5
I have found that my setup of Docker with WSL 2 (Ubuntu 20.04) uses this location at Windows 10:
C:\Users\Username\AppData\Local\Docker\wsl\data\ext4.vhdx
Where Username
is your username.
Related videos on Youtube
Brad
Updated on April 28, 2022Comments
-
Brad about 2 years
I'm trying to learn docker at the moment and I'm getting confused about where data volumes actually exist.
I'm using Docker Desktop for Windows. (Windows 10)
In the docs they say that running docker inspect on the object will give you the source:https://docs.docker.com/engine/tutorials/dockervolumes/#locating-a-volume
$ docker inspect web "Mounts": [ { "Name": "fac362...80535", "Source": "/var/lib/docker/volumes/fac362...80535/_data", "Destination": "/webapp", "Driver": "local", "Mode": "", "RW": true, "Propagation": "" } ]
however I don't see this, I get the following:
$ docker inspect blog_postgres-data [ { "Driver": "local", "Labels": null, "Mountpoint": "/var/lib/docker/volumes/blog_postgres-data/_data", "Name": "blog_postgres-data", "Options": {}, "Scope": "local" } ]
Can anyone help me? I just want to know where my data volume actually exists is it on my host machine? If so how can i get the path to it?
-
Nag about 4 yearsdid you find the solution to see where they "actually" stored ? It is very easy in Docker toolbox to verify, we can log in to the docker-machine and check. However, I didn't find a way yet to verify where those volumes exist in the case of Docker Desktop
-
Brad about 4 yearsSee the accepted answer
-
-
Brad about 7 yearsOk so the source
/var/lib/docker/volumes/blog_postgres-data/_data
is the linux VM docker is running on. My main curiosity here is that sharing images etc is great but how do I share my data? can I push a volume to docker-hub like I do with images? can I make backups etc? -
shizhz about 7 years@Brad, I updated my answer for your questions because comment is not enough, hope it could be helpful to you :-)
-
BMitch about 5 years@Brad you can mount the same named volume in multiple containers. So
docker run -it --rm -v blog_postgres-data:/data busybox ls -l /data
will show that data. -
al45tair almost 5 yearsI realise this is a couple of years old, but it's probably worth pointing out that Docker for Windows does not presently use Windows Subsystem for Linux; rather, it runs Moby Linux inside HyperV.
-
theeranitp almost 4 yearsYour answer is correct "When running linux based containers on a windows host, the actual volumes will be stored within the linux VM and will not be available on the host's fs" I could not find any items in "C:\Users\Public\Documents\Hyper-V\Virtual hard disks" folder.
-
Aaron Axvig almost 4 yearsAnd it appears that Docker Desktop is very willing to simply blow away that VM. For instance I tried to change something in the JSON file in Docker Desktop > Settings > Docker Engine and it was apparently invalid. After Docker Desktop tried to restart a few times, I happened to be watching in Hyper-V Manager and it just deleted the VM.
-
Leos Literak over 3 yearsDirectory "C:\Users\Public\Documents\Hyper-V\Virtual hard disks" is empty (Wondows 10 Enterprise)
-
sushil over 3 yearsBut dbstore is exited. How to view/download the data?.
-
İbrahim Sakacı over 3 yearsThank you, I was searching for the answer nearly two hours :)) Saved my day.
-
Sarel Botha over 3 yearsHoly mother, I cannot believe how long it took before I found your answer and the solution. I looked in a ridiculous number of places. I guess this is a brand new thing. Thanks so much.
-
Dĵ ΝιΓΞΗΛψΚ over 3 yearsthank you! this was a lifesaver even after 2 years. i'm writing this comment in 2020 :-)
-
Gigino over 3 yearsDirectory "C:\Users\Public\Documents\Hyper-V\Virtual hard disks" is empty for me also
-
mpc-DT over 3 yearsHappy to have helped!
-
David over 3 yearsMore generally
/var/lib/docker/
maps to\\wsl$\docker-desktop-data\version-pack-data\community\docker\
-
hyamanieu over 3 yearsYour Docker is eventually managed by Hyper-V (unless you use WSL2). It could be under ProgramData\DockerDesktop
-
Pixelartist over 3 yearsVery confusing - this was correct for me as well.
-
ill over 3 yearsYou can find it in C:\ProgramData\Docker but "ProgramData" is a hidden folder. The subfolder \volumes will contain everything you can find via "docker volume ls"
-
Leônidas Villeneuve about 3 yearsThanks for this. I've been struggling to find the correct path. Where did you find out the correct folder? Most answers on the web are outdated and inaccurate for the latest version, pointing to now empty/inexistent folders.
-
wlnirvana about 3 yearsThis worked for me, but I am also wondering if this is explicitly documented anywhere in the official docs.
-
JohnC almost 3 yearsStill applies for Docker Desktop 3.5.0, Win 11 21H2 (OS build 22000.120)
-
Tanzim Chowdhury over 2 yearsAwesome, thanks so much. For any windows user who is still confused, simply copy-paste this path \\wsl$\docker-desktop-data\version-pack-data\community\docker directly into your file explorer and it will work :D
-
gargoylebident about 2 years@AaronAxvig wait so you just lost all of your data like that? How is that an okay thing? So they give us no ability to back it up (because the volume is apparently nowhere to be found) and it can just be gone like that? What's the point of Docker again if you can just lose all your data like that?
-
gargoylebident about 2 years@wlnirvana yeah like what the heck? Do the folks at Docker assume we don't care about losing our data?
-
dibery almost 2 yearsFound mine in
\\wsl$\docker-desktop-data\data\docker\volumes
. Not sure why my path is different. -
mpc-DT almost 2 years@dibery: you may have a newer version of Docker. Could you please share your Docker version
-
dibery almost 2 yearsDocker Desktop version 4.9.0, and Docker Engine 20.10.16.
-
mpc-DT almost 2 yearsOk, they might have changed the directory for newer version. I edit my post with your provided information.