I’m using some lxc containers to offer services with less resources than full virtualization (like kvm, virtualbox, etc.) demands for.

At first I was creating the containers I needed basically following Chris Willing’s guide but, being jealous 😛 of the existing templates for the debian based distributions that allow creation of containers with a single command, I tried to assemble one for slackware 13.37, that I personally use at work and at home as a virtualization platform.

The concept is simply reapplying the steps that the slackware setup normally follows but with the necessary changes (mainly omissions) to fit our container environment: so I uncompressed the slackware setup initrd to check Patrick Volkerding’s work

and had a look at the install shell scripts in /usr/lib/setup.

Then I took as a base the existing lxc-debian template and modified it to:

– download some slackware packages for a minimal installation (many thanks to Vincent Batts for the selection);

– install them in a folder;

– apply all the standard postinstall routines;

– apply the necessary container fixes (many thanks to Chris Willing that pioneered on this and documented it well 🙂 ).

I published the result on github


“…ok, that’s enough!

we want to play with containers too!”

I was getting to it 🙂

If you want to try them you have to decide which kind of networking you want for them: choices are basically between using:

– a network bridge on your network interface, with the containers in the same network segment as the host;

– a network bridge on a dummy interface used as gateway with NAT: the containers will be in a private network segment.

If you want to offer services and you have plenty of ips to use (like in an home network), maybe the first solution can be easier, as you don’t have to use iptables to redirect incoming connections to the private network of the containers.

Slackware-13.37 kernel already supports all you need, so let’s setup our interface, assuming our host eth0 (the primary ethernet interface, in the example) address is and that we are in a class C network with as our gateway.

Here are the step to follow in each situation:

containers on the same network segment as the host

We have to put the interface down because we are going to add it to the bridge, so if you’are doing this through an ssh connection, I suggest you to run this as a script in a screen session, to avoid being cutted off 😉

At the end the bridge setup should be ok: you can find a version of the script above (to be included in /etc/rc.d/rc.local) here; I also modify /etc/rc.d/rc.inet1.conf on my nodes where I use this configuration to omit eth0 config (the script is enough to bring up the interface on the host running the containers).

Next, we create a configuration file, let’s call it chuckd.config, for the chuckd virtual container that we are going to do: decide a custom hardware address (anything valid should do) and ip (as we said, in the same range)

containers on a natted private network

In this case the script to bring up the private network is this

at the end of the script you can see some example of redirection of incoming connections toward the containers in the private network.

also the config file changes (with an ip on the same network)

– – –

Now we’ll setup our template so we can use it to create the container: change directory to /usr/lib/lxc/templates if you are on a 32 bit system

We are ready to create our first container, chuckd, using lxc-create and a slackware mirror: if not specified, defaults to the main one; here I’m using a local copy

wait some seconds (25, here) and you will have your slackware-13.37 minimal container in /var/lib/lxc/chuckd/rootfs 🙂

But you have to do another step before firing it up, and it’s setting the network parameters in /var/lib/lxc/$container/etc/rc.d/rc.inet1.conf to the one of your network, if you don’t have a dhcp server available

(, and, in the nat example above) and a nameserver in /var/lib/lxc/$container/etc/resolv.conf (here I’m using google’s one)

Then launch a screen session and fire up the container

you’ll see something like this

and the console output will stop there: that means that the container fired up successfully! 🙂

Having it in a screen session means that you can detach the session (ctrl-A D) and reattach when needed (screen -D -r), it’s optional but useful.

After launching, you can connect to its ip via ssh or open a console with

You can install whatever package you use (also full package sets) with slackpkg, but you can alternatively use slapt-get, if you like.

Enjoy virtual containers!

Considerations: lxc aims to process isolation and at the moment it’s not full: the template sets in the default config to start the containers with lxc.cap.drop=sys_admin, but that line can be commented out from the template or per container, if needed.

P.S. if you want to specify your own set of packages for the container, just create a text file with a modified version of this list, following the same syntax

then source it before launching lxc-create

you can also pass to the script a custom SUITE variable to use other versions than 13.37 (but this is untested, as PACKAGES has to be changed too for each SUITE).

P.P.S. 14.9.2011: edited the nat bridge script following Chris Willing’s hints (thanks again! 🙂 ).


Linux Containers (LXC) on Slackware© 13.37 (Chris Willing)

LXC HOWTO (Dwight Schauer)

– <a href=https://sourceforge.net/mailarchive/forum.php?forum_name=lxc-users>lxc-users mailing list

– <a href=https://sourceforge.net/mailarchive/forum.php?forum_name=lxc-devel>lxc-devel mailing list