Skip to content

Instantly share code, notes, and snippets.

@ewindisch
Created December 2, 2014 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ewindisch/3847a7233a08b63cde73 to your computer and use it in GitHub Desktop.
Save ewindisch/3847a7233a08b63cde73 to your computer and use it in GitHub Desktop.
Dockerfile-ish output from image (from cwd of a 'docker save' extraction)
#!/usr/bin/python
import json
import sys
img_id = sys.argv[1]
#json_f = open("%s/json" % head)
#img_json = json.load(json_f)
#json_f.close()
traversal_list = [img_id]
while True:
json_f = open("%s/json" % img_id)
img_json = json.load(json_f)
json_f.close()
parent = img_json.get('parent', None)
if parent is None:
break
traversal_list.append(parent)
img_id = parent
traversal_list.reverse()
print "Created image hierarchy"
print traversal_list
for img_id in traversal_list:
json_f = open("%s/json" % img_id)
img_json = json.load(json_f)
json_f.close()
parent = img_json.get('parent', None)
if parent is None:
for k, val in img_json['container_config'].iteritems():
print k, val
continue
parent_json_f = open("%s/json" % parent)
parent_json = json.load(parent_json_f)
parent_json_f.close()
for k, val in img_json['container_config'].iteritems():
if k == "Image":
continue
if not k in parent_json.get('container_config', {}):
print k, val
continue
if val != parent_json.get('container_config', {})[k]:
print k, val
continue
img_json = parent_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment