Skip to content

Instantly share code, notes, and snippets.

@lgs
Forked from kennedyj/list-volumes.py
Created April 24, 2014 08:16
Show Gist options
  • Save lgs/11246177 to your computer and use it in GitHub Desktop.
Save lgs/11246177 to your computer and use it in GitHub Desktop.
#!/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