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).
I use this handy function to list the content of my volumes:
dvolume() {
local volume volumes_to_list=${1:-$(docker volume ls --quiet)}
for volume in $volumes_to_list; do
sudo ls -lRa "$(docker volume inspect --format '\{\{ .Mountpoint }}' "$volume")"
echo
done
}
Notice you can call the function in two ways:
$ dvolume # for each volume, list its content
$ dvolume <volume> # list <volume>'s content
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