Wednesday, January 21, 2015

Open Media Vault and Docker, Part 2

Continued from Part 1.

So Docker is pretty cool.  And I think it could solve a few problems I have.  I currently run Open Media Vault on an HP N40L microserver as my NAS, as an application server and as a general "do anything" box.  The problem is that any time I monkey around with the box, such as installing experimental software, I run the risk of breaking something.  And while it's not a serious business machine, I really don't want the potential disruptions.

In most business scenarios, you'd typically run TWO machines -- one to serve as a development and/or testing environment, and the other to serve as a production environment.  In a situation with constrained resources (like a small business), you might maintain a single physical server, but use virtualisation to maintain separate development and production environments.  And after looking at a number of different virtualisation options, Docker was the only one I could find that really suited my needs -- that is, open source, easy to use, well documented and supported, minimal overhead and ideally, compatible with tools that I'm already familiar with.

So, how do we get Docker up and running on Open Media Vault?

The Docker website has some basic instructions for running Docker on a Debian Jessie system.  There are also instructions for installing Docker on Debian Wheezy (which is the version upon which OMV Krazelic is based), but they are a little bit more involved -- since you need to install a backports kernel.  I suspect these instructions will probably work for OMV, but generally, installing backports kernel is handled through the web interface.  So I recommend the following steps;
  • Follow the steps here to install the  OMV-extras plugin
  • Once the OMV-extras plugin is installed and working, you should see a tab for installing the backports kernel.  Once selected, it will take a little while to download and install.  You'll need to reboot afterwards
  • After the reboot has finished, you'll need to ssh into your machine, and you can continue following the instructions from step 2 -- that is, run  
curl -sSL | sh
  • If you haven't done so already, you may need to instead curl (sudo apt-get install curl)
At the end of the whole process, you should have a working installation on your OMV machine.  Now it's time to try out installing an application.

Open Media Vault and Docker, Part 1

For the past couple of weeks, I've been playing around with Docker, which is rapidly gaining popularity as a way to deploy applications across a variety of different environments.  What is it?  Well, as best as I can understand, it basically provides a software interface to operating-system level virtualisation.  What does that mean?  Well, Docker takes a bunch of features available in the Linux kernel, and uses them to allow you to create isolated "containers", which are somewhat akin to virtual machines, but with very minimal overhead.  A lot of people have compared Docker containers to FreeBSD jails -- although, whether it is a relevant comparison depends on who you ask.

But who cares what Docker is?  What can it actually do?  Well, we can take a computer running linux with Docker installed (let's call it the "host") and install an isolated guest container, for the purposes of running particular software.  When the software is no longer required, the container shuts down.  It can be deleted if it is no longer needed, it can remain dormant until required again, or a snapshot of the container can be saved as an image that can be used as a template or starting point for more containers in the future.  The host system itself, remains untouched.  Furthermore, the container doesn't have to be the same version of linux as the host... it doesn't even need to be the same distribution.  For example, you could run Fedora as your host, but use Debian for a container.

What gets people really excited about this, is that it can make it really easy to deploy new applications.  If I write a piece of software for linux, it could end up being deployed to systems running Fedora, Debian, Slackware, Ubuntu, Arch, or whatever.  While the software will be fundamentally compatible with each of these different distributions, variations in architecture of each distribution make the software installation process slightly different each time.

Alternatively, I could write a simple installation process based on the distribution of my choice, say Debian.  The installation steps are put into a Dockerfile, which uses a standardised set of syntax, and the Dockerfile is made available to end users.  An end user can then run the "docker build" command on the Dockerfile, and they'll end up with a docker container using Debian, and running the software... irrespective of their host distribution.  For a lot of users, this is sort of a "big deal".  It among other things, it allows system admins to manage servers using their preferred distribution, even if the applications they run need to be running in a different distro.  It also allows an admin to mix and match different versions of containers without needing to change the host.  Want to run software the needs Debian Jessie, but don't want to upgrade your host from Debian Wheezy?  No worries, Docker can handle it.

That's pretty cool.

But what's even cooler, is that in addition to working on linux, by using boot2docker, Docker can also be installed on Windows and OSX.  Want to run an application designed specifically for linux, but still use your favourite OS?  Install boot2docker and you have a working Docker environment within a few minutes.  Microsoft must be feeling a bit pinched by Docker, because they've actually announced that they'll be including Docker support in the next version of Windows server.

What's that cracking sound?  I think it's the sound of hell freezing over...