This is an experiment to test out using squashfs based images which have many benefits over the AUFS diffs currently in use:
- Easy to distribute
- Easy to mount
- Easy to checksum / verify
- Easy to share between jobs (mounted once, uses the kernel file-cache)
The aim is to also use squashfs for slugs so they benefit from the above too.
image format
An image is a JSON manifest which contains a list of layers which should be mounted, e.g.:
{
"version": "v1",
"layers": [
{
"id": "3fdfac2f9355dfdb1e3b1af1afdf143acabd555dcd8fc6b80c1ea62423ac2122a634b119140663ee213c0d621d1e51de40ac9cdf8cbaa24ca7a27593ba7d05ff.squashfs",
"type": "squashfs"
},
{
"id": "8d4f80ddb31de6c9a5413c1f0ca1fb4585866e2b966591491ccc0363f2760a644d1512786eb8f5500a873d2da4f0636fa72202b4fcd68e823be8489ac543bd32.squashfs",
"type": "squashfs"
},
{
"id": "385d3eda8d4823312f6e0abcc7925795dd5b587ed333b1d29ebb83fa50dbbbbe1697dcb3e55e01eb9f4d85e76cbdbac3f907d8ff122dd09e27e56cdad8f573d5.squashfs",
"type": "squashfs"
}
]
}
mounting an image
Images are mounted using overlayfs with a lowerdir
for each of the squashfs layers from the manifest (requires Linux >= 3.19, see here), and a temporary upperdir
.
storage
There is a root directory (hard-coded as /var/lib/flynn/image
) with 4 sub-directories:
manifests
- image manifests
layers
- squashfs layer files
mnt
- mounted squashfs layers + mounted overlayfs job mounts
tmp
- temporary files
Images are stored as SHA512.json
, layers as SHA512.squashfs
, with images supporting "tagging" via symlinks (e.g. manifests/cedarish.json
-> manifests/1062edd28317eff4f58be2da2fde33c6fb8477bfe7b788f7c0ce10a83e8a297c.json
)
convert docker -> squashfs
I've added util/imagebuilder
which takes a reference to a Docker image and creates squashfs layers for each tagged layer in the image's history.
For example flynn/slugrunner
is converted to three layers: ubuntu, cedarish and the slugrunner scripts, whereas flynn/controller
becomes two layers: busybox + controller binaries.
The generated layers are tagged with the ID of the corresponding Docker image to avoid converting already converted images.
We probably want to support building squashfs layers from scratch, but converting from Docker images gives us a good starting point.
Flynn partially boots but I had some instances of files being missing, but thought it was worth getting feedback on what has been done so far.
/cc @titanous @josephglanville