User Tools

Site Tools


LXC or Linux Containers is a lightweight virtualization technology available on Linux. Guest and host share the same kernel, guests are limited using cgroups and namespaces.

Creating a new container

The easiest way to get started and set up a container is using the download template. This will download a tarball with a distribution of your choice and install it without any special requirement on the hosting system. LXC tools in TurrisOS are patched to use our server where we provide some distribution tarballs. Those are mostly what those distributions provide without any major modification by us. To install a new container, you can use either CLI or you can get the container deployed via LuCI.

For now you need to use SSH to install LXC containers.
Installing containers via GUI isn't working. See Errata.

In CLI, you can use lxc-create -t download -n my_first_vm to create a new container with the desired distribution. It shows you the available options and lets you choose which distribution you would like to use and, in some cases, which version.

You can do the same in LuCIServicesLXC Containers. As you can see in the screenshot bellow, functionality is pretty much the same - you choose the name of your new container and the distribution you want to use. Then you click on Create and wait for a moment till your container is created. This can take a while and unfortunately compared to CLI, you can't see the progress and there is no error reporting yet.

All newly created containers will have one virtual network card that will be connected to your LAN bridge by default, so it will be just another (this time virtual) computer on your local network and you can treat it as such in regards to IP assignment, port forwarding or firewall setup on your router.

Using your container

First thing you should do in the new container is to setup a strong password. That has to be done through CLI. If you call lxc-attach -n my_first_vm, you will get a root shell inside the container. You can set your password using passwd command from there. Maybe setting up the network (if you need anything special) and SSH at this point might be a good idea to get an easier access to the container. Please consult the documentation of your distribution of choice on how to do so.

You can stop and start your container either from the LuCI page or via CLI. The LuCI page also shows whether the container is running or not. To do the same stuff from CLI, use:

  • lxc-start -n my_first_vm
  • lxc-stop -n my_first_vm
  • lxc-info -n my_first_vm

Those commands are pretty self-explanatory.

Starting container at boot

To enable automatic startup of your container at boot time, you need to edit configuration file /etc/config/lxc-auto. Here is an example configuration file:

config container
        option name my_first_vm
        option timeout 60
config container
        option name my_second_vm
        option timeout 120

As you can see, you can have multiple container sections configured. Every container configured here will get started at the boot and each of them will be correctly halted during the shutdown. Set timeout option to specify how much time in seconds do the containers have to gracefully shutdown before being killed. The default value is 300.