Locating data volumes in Docker Desktop (Windows)

I'm on Windows + WSL 2 (Ubuntu 18.04), Docker v19.03. I found my Docker volumes in this location, type in the Windows file explorer :

\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\

You will have one directory per volume.


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 by db1 will persist in the volume of container dbstore.

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 :-)