Create an LXC Application Container using libvirt

LXC application containers are good tools to isolate single applications. Instead of directly creating them using lxc-create you can also create them with libvirt / virsh.

If you have dnsmasq installed and running globally you will get into trouble running net-start default. So follow the advice on
Now let's create the virtual network for virsh (libvirt):

sudo virsh --connect lxc:/// net-start default

If you want to know how the default network is configured, then run sudo virsh net-dumpxml default.

Now create the xml configuration file for the application container, let's say application-test.xml:

<domain type='lxc'>
  <clock offset='utc'/>
    <interface type='network'>
      <source network='default'/>
    <console type='pty' />

(Make sure you adjust emulator to the path where libvirt_lxc is on your system!)

Now you can define this linux container (LXC) using libvirt like this:

virsh --connect lxc:/// define application-test.xml

And start it:

virsh --connect lxc:/// start vm1

If you want to connect to the new container on the terminal, run:

virsh --connect lxc:/// console vm1