[SGVLUG] Setting up lightweight containers of various flavors of Linux?
Dan Kegel
dank at kegel.com
Thu Aug 23 17:21:11 PDT 2012
Line noise update:
lxc as shipped in ubuntu 12.04 seems rather far along,
it appears to be a good way to set up ephemeral chroots;
they seem to take about two seconds to set up and tear down, combined.
Here's a little script to demo ephemeral ubuntu 12.04 and 10.04
guests. (With just a little work, it could use ssh to actually
run commands inside the lxc container instead of abusing
it as a better chroot.)
(Next step for me: update lxc to be able to create centos guests.)
- Dan
# Create the base images if needed
if ! test -d /var/lib/lxc/demo.ubuntu_1204
then
sudo lxc-create -n demo.ubuntu_1204 -t ubuntu -- -r precise
fi
if ! test -d /var/lib/lxc/demo.ubuntu_1004
then
sudo lxc-create -n demo.ubuntu_1004 -t ubuntu -- -r lucid
fi
for os in ubuntu_1004 ubuntu_1204
do
for try in `seq 2`
do
echo Testing ephemeral container with $os, try $try
sudo lxc-start-ephemeral -o demo.$os -d > log.$os 2>&1
while ! grep -a "is running" log.$os
do
sleep 1
done
container=`awk '/is running/ {print $1}' log.$os`
echo 'xyzzy should not exist yet, even on second run.'
if test -f /var/lib/lxc/$container/rootfs/xyzzy
then
echo BUG in $os
fi
sudo chroot /var/lib/lxc/$container/rootfs touch /xyzzy
if test ! -f /var/lib/lxc/$container/rootfs/xyzzy
then
echo BUG in $os
fi
sudo lxc-stop --name $container
done
done
More information about the SGVLUG
mailing list