Skipping Docker for LXC for Local Development.

http://michaeldehaan.net/post/111599240017/skipping-docker-for-lxc-for-local-development

Recently for $work things I had a chance to play around with raw LXC, which has been a great experience thus far.

Ultimately Docker is getting a bit too much hype lately, and I think that hype properly belongs with much of the underlying technology, not the unionfs-esque glue. Given, popularizing Immutable Systems is good work, I’m not sold on Single Entry point. Docker files seem like good ideas, but I find the Docker command line awkard. I find the system names and git-based semantics awkward. I really just want named snapshots.

Simply put, LXC is that and if you just want cheap “baby VMs” inside a Linux box, it’s solid.

sudo apt-get install lxc lxctl lxc-templates

Creating a base image from a template is pretty quick. You should note this is a fairly stripped base image, but it’s easy to customize later:

sudo lxc-create -n ubuntu01 -t ubuntu

Let’s start the VM in the background

sudo lxc-start -n ubuntu01 -d

There’s an lxc-console command that can be used to attach the instance, but control characters can be avoided by SSH’ing into the instance instead.

sudo lxc-ls -f

That will show the IPs. The default login is ubuntu/ubuntu and can sudo to root as you would expect.

To customize the image, log in, do whatever, and make a new snapshot.

sudo lxc-clone old_container_name new_container_name

When done, you can stop containers easily:

sudo lxc-stop -n old_container_name

And get rid of them permanently if you wish:

sudo lxc-destroy -n old_container_name

For most developers merely wanting to save states and easily get back to them, this is all you need. Things we are ignoring here are questions about isolation and security, or even batch mangeability, but that’s not what I was after, and I’m happy. Obviously for any sort of production case there is more to do.

With how easy LXC is, it’s important to not award Docker all the hype. Docker is an intersting deployment paradigm if you are willing to code your apps in a certain way, I like it’s port mapping ideas and such, but simply put, it’s awkward.

Anyway, for working with some tiny VMs inside a Ubuntu VM from my Mac – just for development cases – this works great – and spares me all the “commit” weird stuff that comes from Docker.

I know some people are excited about Docker for deployment, but I think people get excited about it for local development, and I’m not sure the value add for that is quite there.