Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

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?

like image 820
Duane Avatar asked Jan 15 '16 02:01

Duane


People also ask

How can I see the content of a docker volume?

View a Data Volume You can use the docker volume ls command to view a list of data volumes. Use the docker volume inspect command to view the data volume details.

Which command displays a list of volumes created by docker?

docker volume ls | Docker Documentation.

Which command will show a list of volumes for a specific container?

When you run docker inspect myContainer , the Volumes and VolumesRW fields give you information about ALL of the volumes mounted inside a container, including volumes mounted in both the Dockerfile with the VOLUME directive, and on the command line with the docker run -v command.


2 Answers

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

like image 116
Manuel J. Garrido Avatar answered Sep 21 '22 15:09

Manuel J. Garrido


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

like image 35
Vaidas Lungis Avatar answered Sep 21 '22 15:09

Vaidas Lungis