Multi-Server Docker Playground

Docker is an awesome solution to creating a multi-server sandbox environment on your local machine. I’m currently designing a solution for a messaging platform using RabbitMQ by Pivotal (the Spring folks). I needed to prove a concept using two Rabbit brokers. Enter the Docker VM. I was able to quickly prove my concept using two docker images running in one Docker VM (Docker Toolbox).

To do this I first needed Docker. Docker provides a platform to develop, build, and deploy applications. Docker provides an environment in which you can run one or more Docker container images. I got started with DockerToolbox which can be downloaded and used locally on your workstation or laptop. Here’s a link for the DockerToolbox download https://www.docker.com/products/docker-toolbox

Once you’ve installed DockerToolbox, open a Docker Quickstart Terminal and I’m going to show you how to get an image in the public domain to work with. My project requires architecture changes for a RabbitMQ. RabbitMQ is an implementation of a messaging standard called AMQP or advanced message queuing protocol. RabbitMQ runs on different platforms and it’s written in Erlang, an excellent concurrent processing platform. I found the RabbitMQ Docker image in the public domain. The image is freely available so it was chosen as an initial image. Here’s how to get the image on your local computer using Docker. Type the following in your Quickstart Terminal.

Once the rabbitmq image is pulled, you can run it. In my case I needed 2 RabbitMQ brokers running in the same Docker container. You will need to run each machine on a different port. Rabbit communicates by default on 5672 and the web administration application uses 15672. The second Rabbit broker needs to use different ports, 5673, and 15673 respectively. Start both instances in the docker container like so.

To see your new running machines, use the following command:

These images are now running RabbitMQ brokers. Before I could check them with the web management application (using a browser) I had to enable the Rabbit management plugin. Also, I needed Federation capability so these plugins need to be enabled as well. Here are the Rabbit documentation pages that have the commands for enabling these plugins:

The commands needed are:

Since, these commands need to be run on each instance, you could log into each instance using the Docker Quickstart Terminal, however there’s an easier way and that’s to use the Docker exec command. You can get help for any command like so:

To use the exec command you’ll need the two names of your new instances. Mine are listed above, naughty_davinci and mad_carson. Enable everything like so:

When you opened the Docker Quickstart Terminal, an IP was acquired, something close to 192.168.99.100. You’ll start the web management applications using the following URLs.

Click on the Admin menu link on the right top of the application and be sure you see the links about the federation features.

Now that you have a running Docker container with two Rabbit brokers you can do your prototyping. This is how I tested Federated queues. The problem is that when you stop the instances or restart your local machine you will lose everything you’ve done. The key part you don’t want to repeat would be the plugin enabling because it really defines your Rabbit broker images.

I now have a public rabbitmq image with enabled plugins now at https://hub.docker.com/r/dlwhitehurst/fed-rabbit/

You can skip the steps to enable the plugins by just pulling my image from the Docker hub. You only need this to setup two running RabbitMQ brokers.

Leave a Reply

Wow, 3,768 people read this.