Skip to content

Instantly share code, notes, and snippets.

@kennedyj
Last active August 29, 2015 14:00
Show Gist options
  • Save kennedyj/11017298 to your computer and use it in GitHub Desktop.
Save kennedyj/11017298 to your computer and use it in GitHub Desktop.
List docker volumes
#!/usr/bin/python
# e.g. docker ps -a | grep 'my name' | awk '{print $1}' | xargs docker inspect | ./volume-list.py
import json
import fileinput
raw = []
for line in fileinput.input():
raw.append(line)
data = json.loads(''.join(raw))
volumes = [(k, v) for i in data for (k, v) in i['Volumes'].items()]
for v in volumes:
print '%s,%s' % (v[0], v[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment