As of today creating libvirt lxc system container root file system is a pain. Docker's fun came with its image sharing idea... why couldn't we do the same for libvirt containers? I will expose here is an attempt at this.
To achieve such a goal we need:
- container images
- something to share them
- a tool to pull and use them
OpenBuildService thanks to kiwi knows how to create images, even container images. There even are openSUSE Docker images. To use them as system container images, some more packages need to be added to those. I thus forked the project on github and branched the OBS projects to get system container images for 42.1, 42.2 and Tumbleweed.
Using them is as simple as downloading them, unpacking them and use them as a container's root file system. However, sharing them would be so fun!
There is no need to reinvent the wheel to share the images. We can just consider them like any docker image. With the following commands we can import the image and push it to a remote registry.
docker import openSUSE-42.2-syscontainer-guest-docker.x86_64.tar.xz system/opensuse-42.2 docker tag system/opensuse-42.2 myregistry:5000/system/opensuse-42.2 docker login myregistry:5000 docker push myregistry:5000/system/opensuse-42.2
The good thing with this is that we can even use the
docker build and
Dockerfile magic to create customized images and push them to the remote
Now we need a tool to get the images from the remote docker registry. Hopefully there is a tool that helps a lot to do this: skopeo. I wrote a small virt-bootstrap tool using it to instanciate the images as root file systems.
Here is how instanciating a container looks like with it:
virt-bootstrap.py --username myuser \ --root-password test \ docker://myregistry:5000/system/opensuse-42.2 /path/to/my/container virt-install --connect lxc:/// -n 422 --memory 250 --vcpus 1 \ --filesystem /path/to/my/container,/ \ --filesystem /etc/resolv.conf,/etc/resolv.conf \ --network network=default
And voila! Creating an openSUSE 42.2 system container and running it with libvirt is now super easy!