No, I didn't mean like that!

I've heard of this "containerization technology" for a while now, and if you have too you've probably heard of Docker. Unfortunately Docker isn't very Windows friendly at the moment, Linux kids get all the cool stuff.

Well lucky me when I stumbled across spoon.net, which gives you the ability to create actual Windows containers!

Lets play with Spoon! Since these days we're all busy passing messages around on RabbitMQ lets build a spoon image for RabbitMQ and then start up a new RabbitMQ container.

Creating a Spoon Image

First things first, create an account on their website then download and install their plugin.

After installation open up an administrative command prompt and type spoon version which should result in (you may have a newer version):

C:\Users\Denny>spoon version  
Version: 1.4.822.0  

Next we need to login to spoon using the account we created earlier by typing (replace username and password with your account credentals):

spoon login <username> <password>  

I've found you only need to login once and future command line sessions continue to maintain your information.

For the following spoon images we're going to be using a spoon.me file. These SpoonScripts contain instructions to automatically package applications.

Erlang

Because RabbitMQ relies on Erlang we'll need to create an Erlang spoon image first. I've gone ahead and created and tested the script. It has been pulled into Spoon App's Github at: https://github.com/spoonapps/spoonme/blob/master/erlang/spoon.me

It's a fairly straight-forward, batch-like script. It's essentially starting from a clean base image and will include wget so we can download Erlang. The script downloads and installs Erlang, adds some environment variables, and cleans itself up.

Download, copy-and-paste, or clone the Erlang spoon.me file into your machine. Head back to your command prompt and run the following to create a new Erlang image on your machine:

Note that Erlang is fairly large, around 100MB, and will be downloaded when building the image.

Change the path below to the correct path of the Erlang spoon.me file.

spoon build -n=erlang C:\path\to\erlang\spoon.me  

You'll note that aside from downloading Erlang the image creation is quite fast. That's because we're not packaging an entire OS along with the image like you would do with typical VM's.

Once the image creation is done type spoon images, you should see a list of all images that have been loaded into your system:

C:\Users\Denny>spoon images  
ID        Name             Tag   Created                 Size  
--        ----             ---   -------                 ----
cc0aacc5  erlang                 1/18/2015 11:36:45 PM   290.1MB  
78f8c1b3  spoonbrew/clean  18.0  12/17/2014 3:37:37 PM   80.5MB  
7ccc788c  gnu/wget               11/25/2014 11:02:13 AM  2.9MB  

As expected we have a new erlang image. Along with that we also have spoonbrew/clean which is a base "clean" image that we start off with. Additionally we have gnu/wget which is the wget image that we also included so that we could use wget to download Erlang. We can now create containers based on the Erlang image, but lets verify the image works by creating a test container.

Test run the Erlang image

Lets verify that we can create an Erlang container based on the image we just created. To do this we're going to use the spoon try command. This command builds a temporary container, when you exit the container it gets deleted.

In your command line run the following:

spoon try erlang  

You should get a new container window with the container id prefixed on the command line. In the new command line window lets open the Erlang shell and run some code by doing the following:

(6e31277f) C:\>erl
Eshell V6.3  (abort with ^G)  
1> 1+2+3+4+5.  
15  

As you can see the Erlang Shell started inside of our container and we successfuly ran some code. Awesome! Type ctrl+c to exit the Erlang Shell and then type exit to exit the container.

RabbitMQ

Now that we have an Erlang image we can create a new RabbitMQ image. We're going to create another spoon.me file, this time specifically for RabbitMQ. As with Erlang I've gone ahead and created and tested a RabbitMQ script. It has been pulled into Spoon App's Github at: https://github.com/spoonapps/spoonme/blob/master/rabbitmq/spoon.me

Inspecting the script we see that we're now starting with:

from erlang  
using wget  

We're starting off with the Erlang image we created earlier and temporarily using the wget image to download RabbitMQ.

One of the many cool things about Spoon is that we can start with any base image, even multiple base images. Because of this creating a new image with all your dependencies is super simple, example: from apache,php,mysql

The using instruction adds temporary image(s) to the container.

The script downloads RabbitMQ, installs RabbitMQ and the rabbitmq_management plugin, sets environment variables, sets a start up script, and cleans itself up.

Download, copy-and-paste, or clone the RabbitMQ spoon.me file into your machine. Head back to your command prompt and run the following to create a new RabbitMQ image on your machine:

Change the path below to the correct path of the RabbitMQ spoon.me file.

spoon build -n=rabbitmq C:\path\to\rabbitmq\spoon.me  

When building or running RabbitMQ you may be asked to allow erlang/rabbitmq to access the network via Windows Firewall

Just like we did with Erlang lets start a temporary container using our newly created RabbitMQ image to verify that it works as expected. In the command line run the following:

spoon try rabbitmq  

The container will start and run a default instance of RabbitMQ. At this point you can use the default user guest/guest to login to the manegement interface. Open your favorite browser and navigate to http://localhost:15672 and login.

RabbitMQ Management Interface

You now have a clean container running RabbitMQ. When you're done poking around simply run exit in your container's command line. Since this is a temporary container (because we used the try command) it will be deleted upon exiting.

You can spin up a non-temporary container by running:

spoon run rabbitmq  

You can find additional paramters for the run command at https://spoon.net/docs/reference#run

What next?

Spoon images and containers are much more powerful than what I've shown you above and Spoon has a ton of more interesting stuff. I would suggest visiting the resources below to dive more into their awesome technology.

A few other Spoon resources that you may find interesting:

Happy hacking!