Parsing docker (1.8) volume info
Volume inspect information was changed in Docker version 1.8 from a "Volumes" list to a new "Mounts" array. See my previous volume parsing post for parsing on Docker <=1.7
Getting a list of volume paths
The Mounts
section, if you do docker inspect <container name or id>
, is structured like this:
"Mounts": [
{
"Name": "e6c202f832b24e488cedfd0e134db439496c245a4d28f8d6345bb18f55aa61b4",
"Source": "/var/lib/docker/volumes/e6c202f832b24e488cedfd0e134db439496c245a4d28f8d6345bb18f55aa61b4/_data",
"Destination": "/dirinmycontainer",
"Driver": "local",
"Mode": "",
"RW": true
}
],
To list all volumes and associated container paths for a docker (1.8.x) container, using go templating:
docker inspect --format='{{range $mount := .Mounts}}{{$mount.Source}} -> {{$mount.Destination}}{{"\n"}}{{end}}' <container name or id>
which will return
/var/lib/docker/volumes/e6c202f832b24e488cedfd0e134db439496c245a4d28f8d6345bb18f55aa61b4/_data -> /dirinmycontainer