List of Docker container volumes

How can I list all volumes of a Docker container? I understand this should be easy to get, but I can't seem to find how.

Also, is it possible to retrieve the volumes of deleted containers and delete them?

+3


source to share


4 answers


You can use docker ps, get the container id and write:

$ docker check container_id

like here:



"Volumes": {
  ..
},
"VolumesRW": {
  ..
}

      

This will give you all the volumes of the container.

+3


source


Use this:



docker inspect --format='{{.HostConfig.Binds}}' <container id>

      

+2


source


You must try:

docker inspect <container> | grep "Volumes"

Glad it helped!

0


source


docker inspect

provides all the information you need. Using grep to filter the output is not very good. This option is --format

docker inspect

better suited for filtering the output.

For docker 1.12 and possibly earlier, this lists all volumes :

docker inspect --format='{{range .Mounts}}{{.Destination}}  {{end}}' <containerid>

      

You can add whatever information you like from the validation data in your release and use the go template language to validate the output as per your needs.

The following output will display all local volumes as in the first example, and if it is not a local volume it also prints the source with it.

docker inspect --format='{{range .Mounts}}{{if eq .Driver "local"}}{{.Destination}} {{else}} {{.Source}}:{{.Destination}} {{end}} {{end}}' <cid>

      

0


source







All Articles