Monday, January 24, 2011

How to setup LXC containers in Debian

LXC Linux Containers provides the resource management through the control groups aka process containers and resource isolation through the namespaces.


  1. The basic installation of lxc containers requires three package:
    apt-get install bridge-utils debootstrap lxc
  2. We need to mount the virtual control group file system on /cgroup:
    mkdir /cgroup
    echo "cgroup /cgroup cgroup defaults 0 0" >> /etc/fstab
    mount -a

Network Bridge

  1. Add network bridge to primary network interface (file /etc/network/interfaces):
    # The primary network interface
    #allow-hotplug eth0
    #iface eth0 inet dhcp
    auto br0
    iface br0 inet dhcp
          bridge_ports eth0
          bridge_fd 0
          bridge_maxwait 0
          bridge_stp off
  2. Restart networking:
    /etc/init.d/networking restart
What is amazing about lxc is how it is savy to resources. A newly started container takes not much but just extra 1M of memory.

No comments :

Post a Comment