How to list the content of a named volume in docker 1.9+?

You can see where docker is storing a volume by running docker volume inspect <volume>.

But there's a caveat: You can't directly see the contents of volumes on Mac and Windows. This occurs because Docker actually runs a Linux VM to be able to containerize, since containzerzation is native functionality for Linux but not these others OSes. So the path that appears is actually the path inside the VM, and not on your host system.

You can access these volumes by using the methods mentioned in the other answers (create a ephemeral container just to view the content) or you can access these directly.

For Mac

For Mac, you can use screen to get access to the VM, like so:

# This path can be slightly different on your system
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

And once there, you can navigate to the path that docker volume inspect gave you.

For Windows

With Docker Desktop & WSL2

Navigate to \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes in Windows Explorer


docker run --rm -i -v=postgres-data:/tmp/myvolume busybox find /tmp/myvolume

Explanation: Create a minimal container with tools to see the volume's files (busybox), mount the named volume on a container's directory (v=postgres-data:/tmp/myvolume), list the volume's files (find /tmp/myvolume). Remove the container when the listing is done (--rm).


you can run docker volume inspect postgres-data

and see Mountpoint section of the result

therefore source parameter will point to host directory maybe /var/lib/docker/volumes/[volume_name]/_data directory

Tags:

Docker