I’ve been working on a pair of tools for manipulating OCI images:
- genoci, for GENerating OCI images, builds images according to a recipe in yaml format.
- lpack, the layer unpacker, unpacks an OCI image’s layers onto either btrfs subvolumes or thinpool LVs.
See the README.md for both for more detailed usage.
The two can be used together to speed up genoci’s builds by reducing the number of root filesystem unpacks and repacks. (See genoci’s README.md for details)
While the project’s readme’s give examples, here is a somewhat silly one just to give an idea. Copy the following into recipe.yaml:
cirros: base: empty expand: https://download.cirros-cloud.net/0.3.5/cirros-0.3.5-i386-lxc.tar.gz weird: base: cirros pre: mount -t proc proc %ROOT%/proc post: umount %ROOT%/proc run: ps -ef > /processlist run: | cat > /usr/bin/startup << EOF #!/bin/sh echo "Starting up" nc -l -4 9999 EOF chmod 755 /usr/bin/startup entrypoint: /usr/bin/startup
Then run “./genoci recipe.yaml”. You should end up with a directory “oci”, which you can interrogate with
$ umoci ls --layout oci empty cirros cirros-2017-11-13_1 weird weird-2017-11-13_1
You can unpack one of the containers with:
$ umoci unpack --image oci:weird $ ls -l weird/rootfs/usr/bin/startup -rwxr-xr-x 1 root root 43 Nov 13 04:27 weird/rootfs/usr/bin/startup
I’m about to begin the work to replace both with a single tool, written in golang, and based on an API exported by umoci.
The opinions expressed in this blog are my own views and not those of Cisco.