List Volumes in Docker Containers

With Docker 1.8.1 (August 2015), a docker inspect -f '{{ .Volumes }}' containerid would be empty!

You now need to check Mounts, which is a list of mounted paths like:

1
2
3
4
5
6
7
8
9
10
11
12
{
"Mounts": [
{
"Name": "7ced22ebb63b78823f71cf33f9a7e1915abe4595fcd4f067084f7c4e8cc1afa2",
"Source": "...",
"Destination": "...",
"Driver": "local",
"Mode": "",
"RW": true
}
]
}

If you want the path of the first mount (for instance), that would be (using index 0):

docker inspect -f '{{ (index .Mounts 0).Source }}' containerid

Pretty print the whole thing:

docker inspect -f '{{ json .Mounts }}' containerid | python -m json.tool

Or use the jq command:

docker inspect -f '{{ json .Mounts }}' containerid | jq