[lxc-users] Building custom LXC templates
Lars Hupel
lars at hupel.info
Mon Apr 18 13:38:24 UTC 2016
Dear list,
I'm a happy user of LXC using an Ubuntu 14.04 LTS host. So far, I've
used a stock Ubuntu container template and installed some stuff in it.
Here is how I set it up, using unprivileged containers:
$ lxc-create -n base -t download --bdev dir -- -d ubuntu -r trusty -a amd64
$ mount -o bind /dev/ ~/.local/share/lxc/base/rootfs/dev
$ chroot ~/.local/share/lxc/base/rootfs/
# install some stuff ...
$ umount ~/.local/share/lxc/base/rootfs/dev
The ~/.config/lxc/default.conf looks like this:
lxc.id_map = u 0 10000001 10000
lxc.id_map = g 0 10000001 10000
Note the absence of networking – it is crucial in my scenario that the
running containers have no access to the Internet. After the setup is
done my custom application just clones containers from that "base"
container and throws them away afterwards (using the Python API). So
ideally I only need to set up the "base" container once.
But I'd now like to automate the creation of the "base" container. I was
thinking of taking a stock Ubuntu template and augmenting it with the
things I need, possibly on my local machine, and shipping it to the host
afterwards.
However, I have no idea how to do that. Is it possible to create a
container locally and pack it up to be extracted somewhere else? Would
that even be portable? If so, is there tooling for that? I use
configuration management for everything else already; LXC so far is the
only thing I haven't automated.
Cheers
Lars
More information about the lxc-users
mailing list