docker-layercake
Docker is a pretty cool system for making fast-starting Linux containers. The containers start from a snapshot image, run some task or server, then self-destruct when finished, so each image always starts from a fresh state.
Docker requires lxc (Linux containers), which requires Linux, so on a development laptop (Mac OS X), you need to start up a Linux VM using VirutalBox. This requires a layer cake:
- VirtualBox (https://www.virtualbox.org/) to create a full hardware emulator
- vagrant (http://www.vagrantup.com/) to script the creation and provisioning of a Linux VM inside of VirtualBox
- docker (http://www.docker.io/) to run the containers inside your Linux VM
This project is just a set of scripts and config files to create a docker image on my laptop that can run java and node.js programs. The image could be used as a base for building an image with your favorite server or tool.
I am not using this in production, and neither is the company I work for. Consider it a recipe that worked for me.
You must have VirtualBox and vagrant installed. (They're available from the above links.)
The scripts, in order from the outside in:
setup.sh- Initialize a VM using vagrant.Vagrantfile- Configuration for using "raring" ubuntu (required for docker)vagrant-provision.sh- Run by vagrant, on the VM, to update the current VirtualBox integrationsetup.sh- Reboots the VM to use the new VirtualBox integration, then asks vagrant to run:build-docker-image.sh- Installs docker, fetches the base ubuntu image for docker, installs java and node.js, and saves the new image as "robey/base".
There's also a script to clean up if you want a fresh start, or are tired of playing:
teardown.sh- Destroy the VM and remove any trace of it from vagrant
You'll know this all works when you do:
$ vagrant ssh -c "sudo docker run robey/base java -version"
and:
$ vagrant ssh -c "sudo docker run robey/base node --version"