Create LXC containers for openSUSE LEAP

When speaking of virtualisation (container-wise) there are two major alternatives: Docker and LXC. If I were deploying web applications I would probably go for Docker, very easy to set up a Docker file installing nginx, php-fpm, etc and doing a few commands to set it up. Docker is not designed for running full machines, you can basically just start one command, that’s it. On the other hand, LXC, you get full machines with a minimal virtualisation layer providing excellent performance. The disadvantage is that you will use more space/memory for running something similar to full machines.

This site provides a wide selection of ready container images, however the openSUSE image is version 13.2 which is running out of support. I could use that image and upgrade it, however they ran install patterns-openSUSE-minimal_base without –no-recommends so you get all sorts of interesting stuff like Mesa you will not need on a server. So I decided to build my own image. It is quite easy, you will basically just need a tarball of the rootfs and a metadata file. On an openSUSE machine the rootfs can be created very easily, thanks to the –root option of zypper. I created a bash script to create a rootfs.tgz, just run it with the requested tarball as argument, i.e. sh make-container.sh /home/you/rootfs.tgz and you are good to go. The script looks like this

Now you have a tarball, you will need a metadata.yaml file:

Now you need to pack the metadata.yaml into metadata.tgz. You can import the image into the lxc host in the following way:

Now you are ready to spin up an instance of the image

That’s it. You need to set the hostname in /etc/hostname, you can use lxd to get networking and NAT.

New blog

I decided to erase the old blog and create a new. The main reasons are the contents on the old homepage are not really relevant anymore. Presently, I am mostly focused on openSUSE development, and contribute to various open source projects (I contribute to Kopano core as my daytime job). My writings in the future will be related to openSUSE, so if you are interested in openSUSE, stay tuned!