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

Docker 1.9 added named volumes, so I..

docker volume create --name postgres-data

docker volume ls 

and I get

local               postgres-data

all good so far..

so how do I see what is in the named volume? Is there a way to cd to it on the host system. Like I can for a mounted host directory?


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

Here's one idea...

docker run -it --name admin -v postgres-data:/var/lib/postgresql/data ubuntu

then in the interactive shell

ls /var/lib/postgresql/data 

Better ideas welcome!

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

Notice you can call the function in two ways:

$ dvolume           # for each volume, list its content
$ dvolume <volume>  # list <volume>'s content

Need Your Help

Get tweets of a public twitter profile

java api twitter twitter4j

I have a list of usernames on Twitter whose profiles are public. I wish to get "all the tweets" they have posted from the day they formed their profile. I checked Twitter4J examples on GitHub. Acco...

How to create a callback for "monitor plugged" on an intel graphics?

linux intel xorg udev

I've got an eeepc with an intel graphics. I'd like to hook a script to the event of a monitor plugged via VGA. How to do that?