LXC Ubuntu

My notes on LXC setup with Ubuntu

By default, lxc-create places the container’s root filesystem as a directory tree at /var/lib/lxc/CN/rootfs

apt-get install lxc

aptitude install bridge-utils libvirt-bin debootstrap

lxc-create -t ubuntu -n lxc1

 

This will default to using the same version and architecture as your machine,
additional option are obviously available (?help will list them). Login/Password are ubuntu/ubuntu.

screen -S -d -m lxc-start -n lxc1

lxc-console -n lxc1 -t 1

For our deployment we would want to use cloning for rapid deployment – lxc-clone -o C1 -n C2

changing IP

Setup new
GW Ip to the bridge interface

ifconfig lxcbr0:1 172.18.10.1 netmask 255.255.255.0 up

then add the NAT rules to the ip can route

iptables -t nat -A POSTROUTING -s 172.18.10.0/24 ! -d 172.18.10.0/24 -j MASQUERADE

============

Setup VLAN

apt-get install vlan

vconfig add eth0 200

root@lxc2:~# ifconfig eth0.200
eth0.200 Link encap:Ethernet HWaddr 00:16:3e:71:db:7e
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B
nano /etc/network/interfaces
iface eth0.200 inet static
address 172.18.10.2
netmask 255.255.255.0

ifup eth0.200

root@lxc2:~# cat /proc/net/vlan/eth0.200
eth0.200 VID: 200 REORDER_HDR: 1 dev->priv_flags: 1
total frames received 0
total bytes received 0
Broadcast/Multicast Rcvd 0

total frames transmitted 6
total bytes transmitted 468
Device: eth0
INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
EGRESS priority mappings:
root@lxc2:~#

 

Ref:

 

https://help.ubuntu.com/12.04/serverguide/lxc.html

http://askubuntu.com/questions/293275/what-is-lxc-and-how-to-get-started

One Reply to “LXC Ubuntu”

  1. I will appreciate if someone could introduce me to LXC and tell me how to get started with this technology? In which cases does it make sense to use, and in which should i stay away from it?

Leave a Reply

Your email address will not be published. Required fields are marked *