LXC, from lxc.sf.net, is a very advanced and flexible toolset
and library for managing linux containers. It is very
actively maintained, provides for both system and application
containers, and in particular has really nice ‘templates’ for
creating fedora, lxc, or debian containers, or minimal containers
based on busybox or only offering sshd.
Libvirt-lxc, on the other hand, is very inflexible due to
having to follow the same API as all other libvirt-supported
hypervisors. It is very sparsely documented, and I’m not
sure there is anyone out there actually using libvirt-lxc to run
anything. In the past, I’ve stuck to tiny, hand-built containers
using only debootstrap and ‘/bin/sh’ (-> debootstrap) as the
I use libvirt, and even virt-manager, quite a bit nowadays to
keep my many VMs straight. It’d be nice to also use it for
some containers. That also opens the door to having UEC
create nodes as contaienrs. So I whipped up a pair of scripts to
leverage the great work from the LXC team in building something I
can use with libvirt. You can get them with
bzr branch lp:~serge-hallyn/+junk/lxc-libvirt-scripts
There is a README to show how to use them and how they work.
Basically you just
to create a container ‘u1’, and then
virsh -c lxc:// start u1
to start it. If you haven’t used the lxc ubuntu template before,
the first build takes awhile as the system is debootstrapped.
Future ones are very fast.
And container startup is lightning-fast. I created one and
installed apache to play around a bit. VNC as a user is
trivial, but I’d like to set up a template (through a
lxc ubuntu-vnc template) to automatically set up a vnc
session running gdm. (Mind you, shutdown from inside a
container doesn’t work – you have to just kill init from
But then I noticed that virt-manager doesn’t support
connections to the lxc driver. That’s no good! Fortunately
it didn’t take too much work to shoehorn that in, so you
can get a package at ppa:serge-hallyn/virt.
add-apt-repository ppa:serge-hallyn/virt apt-get update apt-get install virt-manager
I’ll send the diff for that upstream, though I think I should
make the VM creation window work with LXC before I do that.