cookbook/container: example of building+running docker containers.
This got... long... and complicated. But I think it's a really good demonstration of getting redo to do complicated things elegantly. At least, I hope it is.
This commit is contained in:
parent
01497f55e9
commit
3923a7d3f8
38 changed files with 1375 additions and 7 deletions
21
docs/cookbook/container/dockjson.py
Executable file
21
docs/cookbook/container/dockjson.py
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
"""Generate a docker 1.0-style manifest for a docker image."""
|
||||
import json, os, subprocess, sys, time
|
||||
|
||||
j = json.load(open('template.json'))
|
||||
layerid = open(sys.argv[1] + '.list.sha256').read().strip()
|
||||
j['id'] = layerid
|
||||
|
||||
if len(sys.argv) > 2 and sys.argv[2]:
|
||||
parentid = open(sys.argv[2] + '.list.sha256').read().strip()
|
||||
j['parent'] = parentid
|
||||
|
||||
t = time.time()
|
||||
gt = time.gmtime(t)
|
||||
nsec = int(t * 1e9) % 1000000000
|
||||
j['created'] = time.strftime('%Y-%m-%dT%H:%M:%S', gt) + ('.%09dZ' % nsec)
|
||||
|
||||
nbytes = os.stat(sys.argv[1] + '.layer').st_size
|
||||
j['Size'] = nbytes
|
||||
|
||||
json.dump(j, sys.stdout, indent=2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue