LXC containers in practical use on the desktop

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Unlocked Container

To start the container and create a Debian based system, use

$ sudo lxc-create -n Wheezy -t debian

where you can substitute another name for Wheezy. After about 10 minutes, the template will install a Debian system via Debootstrap [8].

The template always installs the stable release of a distribution, which you can change by specifying the release. You can build a Debian from an unstable repository with

$ sudo lxc-create -n Unstable -t debian --release sid

You can create a development version of Ubuntu 15.04 with

$ sudo lxc-create -n Vivid -t ubuntu --release vivid

The templates are built comprehensively and are easily adaptable to your purposes (Figure 3).

Figure 3: The network bridge is already configured.

LXC puts new containers in /var/lib/lxc/<Container-Name> , with the downloaded packages used during preparation in /var/cache/lxc so that further containers based on the same template can be placed within seconds.

Start a container using

$ sudo lxc-start -n <container_name>

You will arrive directly in the container terminal; an added -d will start the container as a daemon in the background. The required username and passwords are indicated at the end of container creation (Figure 4). You should at least change the password. To get a status of the content of all the containers, run:

$ sudo lxc-ls --fancy

You'll see something like what is shown in Listing 1. You can now start the container using

$ sudo lxc-start -F -n wheezy
Figure 4: Setting up a Wheezy container.

Listing 1

List Your Containers

$ sudo lxc-ls --fancy
[sudo] password for ubuntuuser:
NAME    STATE    IPV4  IPV6  GROUPS  AUTOSTART
----------------------------------------------
wheezy  STOPPED  -     -     -       NO

The -F parameter will start Debian Wheezy in the foreground, right there in the terminal you are using. (See the "Beating the Bug" box for troubleshooting tips.)

Beating the Bug

The version of LXC I used seemed to have a bug in it, which, at press time, was still unresolved. When I tried to start the container using

$ sudo lxc-start -F -n wheezy

the program coughed up a bunch of errors. I solved the problem by including

lxc.aa_allow_incomplete = 1

in the file /var/lib/lxc/wheezy/config .

A Window into the Container

You now have a base system in the container that you can build on. Most end users would probably want to run some graphical applications. Meaningful applications are, for example, programs you don't trust, but might need from time to time. These might include Skype or Google Hangouts; even browsers could fall into this category.

There are several ways to get graphical output from an application running in a container. To get a full understanding of how this happens, you can follow the instructions of LXC package maintainer Stéphane Graber [9] then complete the configuration. Other possibilities are using Xspra [10] or Virtenc [11]. In this example, I'll use X2go [12], because it seems to be the easiest solution.

After logging into your container, you first add a new user with

# adduser x2gouser

then you can install a desktop environment of your choice. If you want KDE, for example, you could do:

# apt-get install kde-standard

Of course, you could go for something lighter, such as LXDE for testing instead:

# apt-get install lxde

Add the line deb http://packages.x2go.org/debian wheezy main to the /etc/apt/sources.list.d/debian.list file and save the file. Then, add the repository key with

$ sudo apt-key adv --recv-keys --keyserver keys.gnupg.net E1F958385BFE2B6E

After doing an apt-get update , install the X2go server with

# apt-get install x2goserver

This step will also create an x2gouser user and group and start the server.

Next, install the X2go client on the Ubuntu host:

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:x2go/stable
$ sudo apt-get update
$ sudo apt-get install x2goclient

A PPA is available for the latter.

Buy this article as PDF

Express-Checkout as PDF

Pages: 5

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content