Installing LXC on Debian Wheezy


First install the needed packages:

apt-get install bridge-utils libvirt-bin debootstrap lxc

Then you have to mount cgroup:

echo "cgroup  /sys/fs/cgroup  cgroup  defaults  0   0" >> /etc/fstab
	mount /sys/fs/cgroup

When executing lxc-checkconfig, you should get something like this:

	Found kernel config file /boot/config-3.2.0-4-amd64
	--- Namespaces ---
	Namespaces: enabled
	Utsname namespace: enabled
	Ipc namespace: enabled
	Pid namespace: enabled
	User namespace: enabled
	Network namespace: enabled
	Multiple /dev/pts instances: enabled
	--- Control groups ---
	Cgroup: enabled
	Cgroup clone_children flag: enabled
	Cgroup device: enabled
	Cgroup sched: enabled
	Cgroup cpu account: enabled
	Cgroup memory controller: enabled
	Cgroup cpuset: enabled
	--- Misc ---
	Veth pair device: enabled
	Macvlan: enabled
	Vlan: enabled
	File capabilities: enabled

Then check if the default bridge has been started: 

virsh net-info default

You should have something like this:

Name            default
	UUID            .....
	Active:         yes
	Persistent:     yes
	Autostart:      no
	Bridge:         virbr0

If it's not active yet, try

virsh net-start default

Only if you are running dnsmasq on your server you might want to use these lines in your /etc/dnsmasq.conf (libvirt uses his own dnsmasq for the network environment and may be running into a conflict when binding to network interfaces or IPs):

listen-address=<yourip>
except-interface=virbr0
bind-interfaces

To start the bridge automatically at boot time, do this:

virsh net-autostart default

You can also use brctl show to show information about installed bridges.

When the network is up and running, you're ready to install your first container:

lxc-create -n mycontainer -t debian

When your container is created, edit the following file nano /var/lib/lxc/frontscale/config and add this:

lxc.utsname = mycontainer
	lxc.network.type = veth
	lxc.network.flags = up
	lxc.network.link = virbr0
	lxc.network.ipv4 = 0.0.0.0/24
	lxc.network.hwaddr = 00:FF:AA:00:00:01

This will connect your container to the above bridge.

Now try to start it:

lxc-start -n mycontainer

You can login to the console of your container using

lxc-console -n mycontainer

To stop the container:

lxc-stop -n mycontainer

If you type lxc- and press TAB, you'll see a lot more lxc- commands to explore.