Puppet Provisioning in Docker

Lately I’ve been messing quite a bit with Docker and my mind is pretty blown about how awesome it is. Remember that feeling you had the first time you launched a vagrant instance and had a virtual machine running with your web application in just a few minutes? That’s the feeling I have again playing with docker… pure awesomeness.

Docker is essentially a wrapper around Linux Containers that makes them usable for mere mortals. With docker I can essentially take my application and all of it’s dependencies, bundle them up into a re-usable image and say “Here, run this!” This has a lot of implications for testing, for repeatability and for system provisioning. I must say it is quite impressive to be able to launch a vagrant box and then run multiple isolated instances of services like rabbitmq or redis inside of it.

It’s easy to try out… if you don’t already run linux you can clone the docker repository and try it out in a vagrant virtual instance. There is also a docker puppet module that you can use to install docker on your own machines if you use puppet. Walking through the examples is a good place to start, once you get a good feel for things you can check out the index for containers that others have shared (there’s some good ones out there, especially the ones published by heroku that emulate their stacks).

For fun, I created an image of a rabbitMQ server. After some trial and error I created the following Dockerfile to build a new image from.

Now to generate a new image I just run “docker build < Dockerfile" and wait. Once it is done I am given an image id for the generated image which I can use to tag the image (for those of you following along, "docker tag jamescarr/rabbitmq). Now to run rabbitmq in it’s own isolated environment I can just run “docker run jamescarr/rabbitmq” and see the magic happen. The final piece of the puzzle is you’ll need to run some docker commands to find out what port the ports 5672 and 15672 are exposed as on the host machine, once you have that figured out you should be able to navigate to http://localhost:(WHATEVER PORT 15672 IS) and be greeted by the rabbitmq management console. The next thing I want to figure out along these lines? Run multiple docker instances to emulate a rabbitmq cluster. 😉

  • Jessy Lenne

    Hi there !
    I discovered your blog today and want to thank you for your share 🙂 i found really useful ways to improve my environnement thanks to you !
    Cheers from France !

  • Tiago Boldt Sousa

    Been playing with this in the latest days.
    If you happen to go for the cluster, do leave a link here 🙂

  • Roman Shestakov

    James – thanks a lot for this post – very helpful, do you have an
    example of Vagrant file which allows to run RabbitMq as docker
    container? I have managed to load / start the image but I am still not able to
    connect to the Rabbit docker container management console from the
    browser. Most likely it is related to some incorrect port setup but I just don’t see what is wrong. Is there any chance to build a working Vagrant file?