Installing LXC with a web interface on Ubuntu 16.04

Linux Containers are insanely useful. Whether it be for stopping an application from cluttering your filesystem with it's configuration, or packaging an application for deployment anywhere, they are truly one of the most useful technologies in linux to date, and are only just coming into the limelight.

This tutorial will show you how to install LXC with a web interface for VM-like management.

A quick google search told me that LXC Web Panel looked to be the best solution for this. The only problem was that their project hadn't been updated in quite a while, and was lacking many features.

I was lucky to find a fork of LWP on github which had been updated much more recently, available at https://github.com/claudyus/LXC-Web-Panel.

Step 1 - Installing LXC

sudo apt-get install lxc

Step 2 - Installing from the claudyus ppa

As per the instructions accessible from the github page, install the author's package repository to your system.

Personally I don't like piping random internet scripts into a root shell, so make sure you check the script first.

curl -s https://packagecloud.io/install/repositories/claudyus/LXC-Web-Panel/script.deb.sh | sudo bash

Step 3 - Install LWP

sudo apt-get install lwp

Step 3b - Modify the apt source to work with 16.04

If the last command didn't work (lwp: no packages found), this is a fix.

At the time of writing, the repository doesn't have any 16.04 packages, so we're going to need to 'hack' apt a bit to let us install the older packages for 14.04.

sudo nano /etc/apt/sources.list.d/claudyus.packagecloud.io.list

(this may change - maybe just try cd'ing to the folder and it'll be there)

At the end of each line will be the word 'xenial' which means that you're running Ubuntu 16.04. Change each of these to 'trusty', so we can use the 14.04 packages.

sudo apt-get update
sudo apt-get install lwp

Step 4 - Use LWP

When the installation has finished, as per the page at the aforementioned github URL, copy across the config, edit it to your needs and start LWP.

sudo cp /etc/lwp/lwp.example.conf /etc/lwp/lwp.conf
sudo nano /etc/lwp/lwp.conf #change it to your liking
sudo service lwp start

You can check that it started correctly by running:

sudo service lwp status

By default, LWP starts on port 5000

Go to http://YOUR_IP_ADDR:5000/ in your favourite web browser. Again, from github, the default credentials are:

User: admin Password: admin

A quick tip - when creating new containers, be aware that the web browser will appear to hang for quite a while. If you run top on your computer, you will find that it's actually downloading the relevant linux bindings and things. It'll only take a long time when you're spinning up a particular flavour of linux for the first time, but just give it a bit, especially if you're on a slow connection.

Enjoy using LWP! Creds to https://github.com/claudyus/LXC-Web-Panel for installation instructions (minus the PPA changing bit), and thanks for maintaining such a great open source piece of software.

Published 2016-09-03