You may remember a blog post I wrote some time ago about Java provisioning with Vagrant. Today I’ll be exploring something that rivals and complements that in coolness. Today I would like to tell you about Docker and show you how awesome it is. New to Docker? Here is an intro in their own word: “Docker is an open-source engine which automates the deployment of applications as highly portable, self-sufficient containers which are independent of hardware, language, framework, packaging system and hosting provider.” When I first heard about Docker I reviewed the demo and examples on their site – let’s say it peaked my curiosity. Cheap, zero-penalty containers to deploy services? A VM without the overhead of a VM? Instant replay and reset of image snapshots? I have to try this… Docker provides a streamlined user interface and API over the very cool lxc (Linux Containers) and aufs (advanced multi layered unification filesystem) to configure, spin up, down, set and replay light weight vm-like containers. Below I will provide an example of how to use Docker to deploy a Java application inside a container. I’ll use Stash – the coolsome git repository management tool I work on everyday – as a sample application (but you can replace it with any other Atlassian product or Java application of your choosing). Preparation for Mac users You can skip this section if you are already on Linux. If you’re working on a Mac you have to go through a VM or Vagrant to use Docker: it is only available on Linux (support for the other platforms is in development and planned). Using Vagrant, spin up a recent Ubuntu box by creating the following Vagrantfile and typing vagrant up at a terminal: 1234567Vagrant::Config.run do |config| config.vm.box = "raring" config.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box" config.vm.forward_port 7990, 7991 config.vm.share_folder("vagrant-root", "/vagrant", ".") config.vm.customize ["modifyvm", :id, "--memory", 2048] end In the file we map port 7990 (Stash’s default port) to 7991 on the host so that later we can test the installation from the Mac. After that is complete you can ssh into your box with vagrant ssh and you’re ready to install Docker. (Thanks to robknight for the simple Vagrant setup I am re-using.) Now that you are inside the vagrant VM we can install Docker. Administrative Stuff (Skip freely) On any new box I need vim, curl and git to deploy my .dotfiles otherwise I can’t function properly: 123sudo apt-get install vim curl git curl -Lks http://j.mp/durdn-cfg | bash Install Docker Installing Docker is easy. First we install some kernel extensions needed for it to run: 1sudo apt-get install linux-image-extra-$(uname -r) Then we install software-properties-common which provides us with add-apt-repository: 1sudo apt-get install software-properties-common Add the dotcloud ppa: 12sudo add-apt-repository ppa:dotcloud/lxc-docker sudo apt-get update And finally install Docker with: 1sudo apt-get install lxc-docker Now we are ready to pull a base image which will be the base of all our work: 1docker pull base This will output: 123456789Pulling repository base from https://index.docker.io/v1 Pulling [...]