brctl: network bridges

# create bridge
brctl addbr br0
ifconfig eth0

brctl delif lxcbr0 eth0
brctl addif br0 eth0
dhclient br0

# move VM to other bridge
for IF in $(brctl show | grep veth | sed 's/^[ \t]*//'); do
brctl delif lxcbr0 ${IF}
brctl addif br0 ${IF}

# connect two bridges?
ip link add veth0 type veth peer name veth1
ifconfig veth0 up
ifconfig veth1 up

brctl delif br0 veth0
brctl delif lxcbr0 veth1

# renew ip in VM
lxc-attach -n vm1 -- dhclient

# /etc/network/interfaces
auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp

Update LXC container templates filesystem

echo "wget -q --no-check-certificate $URL -O - | bash -";
echo "

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
echo "


# fix dns
echo "nameserver" > /var/cache/lxc/debian/rootfs-wheezy-amd64/etc/resolv.conf

echo "0 13 * * * root /usr/bin/wget -q --no-check-certificate -O - | bash -" > /etc/cron.d/lxc_update_template
service cron restart

# fix squeeze repository
sed -i 's|||g' /var/cache/lxc/debian/rootfs-squeeze-amd64/etc/apt/sources.list



Add user to docker group
sudo usermod -aG docker $USER
su - $USER

systemctl enable docker
systemctl status docker

Start all exited container
docker start $(docker ps -a -q -f status=exited)

Stop all containers
docker stop $(docker ps -a -q)

# Delete all containers
#docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q) -f

# Delete all images

Install LXC (Linux Containers) under Ubuntu

apt install -y bridge-utils debootstrap lxc-templates lxc

Create container
export LANG=en_US.UTF-8
export CONTAINER=wheezy

sudo sudo lxc-destroy -n ${CONTAINER}
sudo lxc-create -t debian -n ${CONTAINER}
sudo lxc-start -d -n ${CONTAINER}

echo 'Acquire::http::Proxy "http://apt-cacher:3142/";' | sudo tee /var/lib/lxc/${CONTAINER}/rootfs/etc/apt/apt.conf

sudo lxc-attach -n ${CONTAINER} -- apt-get clean
sudo lxc-attach -n ${CONTAINER} -- apt-get update