Search code examples
docker

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?


Solution

  • 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).