'Is there a way to list files inside a docker volume?

Simple question: Is there a docker command to view the files inside a volume?

I run docker for windows which creates a MobyLinuxVM on my machine to run Docker. I can't get a remote desktop connection onto this machine like I can with an Ubuntu VM (which I also have running on my machine).

Therefore, I can't see a way to see what is inside my host volumes (as they are actually inside the MobyLinuxVM), where as if I ran docker on my Ubuntu VM I could remote onto the machine and take a look.

Therefore, is there a way I can run some sort of docker volume command to list what's inside each volume?



Solution 1:[1]

This isn't a direct answer to the question (because it was asking about a docker command) but in case anyone arrives here like I did:

If you have Docker Desktop (on Windows at least) you can explore into a volume using the Docker Desktop GUI. Just click on the volume, then switch to the "Data" tab at the top.

Quick and easy if you are just wanting to take a look around or copy out a file.

Solution 2:[2]

Not sure how widely applicable this is, but if you have root access I've just discovered that you can browse the contents of a volume at /var/lib/docker/volumes/<VOLUME_NAME>/_data. VOLUME_NAME is as shown by docker volume ls.

I'm looking at an Ubuntu 18.04 VM running Docker 19.03.5 - YMMV.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jono Job
Solution 2 J.B