Docker on OS X via Vagrant

Docker is so hot right now, and with good reason. Wrapping up applications/services into ‘containers’ that include all their wants, needs (dependencies) and idiosyncracies whilst being lightweight and portable? Yes please!

You can’t beat a good analogy either, and the whole ‘shipping’ metaphor is a strong one. Add container linking into the mix and building blocks spring to mind. Awesome!

If there is a drawback to Docker, it’s that it requires a Linux kernel to perform its sorcery (at least, for now). On other platforms, the most common way to mess around with Docker is via a project called Boot2Docker. The OS X installer is comprised of the Boot2Docker ISO (based on Tiny Core Linux, with Docker installed), VirtualBox (to run the image) and some helper tools.

This is all very convenient, but what if you prefer something other than VirtualBox? Well, with Vagrant*, you’re good to go. I’ve posted a Boot2Docker v1.3.0 box on Vagrant Cloud. Here’s how to use it:

  1. Create a new folder somewhere to keep the Boot2Docker VM
  2. From the command line, navigate to that folder and
    $ vagrant init sebnash/boot2docker
  3. If you like, take a look at the Vagrantfile and customise. Then it’s time for a good old
    $ vagrant up
  4. Once the VM has booted, access the Boot2Docker shell by
    $ vagrant ssh

Demo video below. Enjoy!

* And one of its plugins (VMware, Parallels).