Getting started with lxc
- Install dependencies
apt-get install lxc debootstrap libpasswd-unix-perl libfile-slurp-perl \ libmoose-perl libpath-class-perl libconfig-inifiles-perl
- Set up networking
Your containers need a way to talk to the interweb. One way is a bridge.
A bridge is basically like a switch. You can plug your
eth0 into it, and
also each container. Then they can all talk to each other and the outside
Put something like this in
auto lo iface lo inet loopback iface eth0 inet manual auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_stp off post-up /usr/sbin/brctl setfd br0 0
If you have a static lease, configure br0 with that information instead of the dhcp line::
iface br0 inet static address [your ip] netmask [your netmask] broadcast [your broadcast] gateway [your gateway] bridge_ports eth0 bridge_stp off post-up /usr/sbin/brctl setfd br0 0
- Put info about networking setup in a file for later use
When containers are created, we need to tell them how to access the network.
Put this in
lxc.network.type=veth lxc.network.link=br0 lxc.network.flags=up
- You're ready!
# Summary of commands lxc --help # Create a container called 'test' lxc test create # Start the container lxc test start # Enter it lxc test enter # Stop the container lxc test stop # Destroy it (you'll be asked to confirm) lxc test destroy
- Starting containers automatically on boot
On ubuntu, install the upstart jobs:
cp upstart/lxc-* /etc/init
And when you create your containers, use -a to flag them as ones that should be automatically started on boot.
If you have a container you already made that you want to start on boot:
Good luck! -- Nigel McNie & Martyn Smith