I bought a new laptop, a Dell XPS 15 and my oh my is it snazzy. The thing I was most excited about was that I’d get to play with Windows containers again. I have 3 other machines in the house but they’re either unsuitable for containers (OSX running Windows in parallels) or I’ve so totally borked them playing with early betas of containers they need to be formatted and reinstalled – possibly also thrown into the sun.
So when I found myself presented with the question “how can we get into messaging in our apps for free?†I figured I’d crack open the laptop and build something with MassTransit. I found that MassTransit supports running on RabbitMQ. Why that sounds like a perfect opportunity to deploy RabbitMQ to a container. The only problem was that I didn’t really know how to do that.
In my heart I felt like running the installer wasn’t quite the right way to go. I’d just copy the installation file into their destination. Problem is that RabbitMQ relies on erlang so I’d have to install that too. So I built a docker file which looked something like
So attempt number two:
That was enough to get Rabbit MQ installed. I still needed to expose some ports for RabbitMQ so I added
Rabbit also likes to know where Erlang lives so some environmental variables for that aren’t going to hurt.
The config file looks like [{rabbit, [{loopback_users, []}]}]. Finally we’ll start the actual rabbit process as the default action of the container:
Now you can log into the management portal using the guest/guest account.
The complete docker file is here:
FROM microsoft/windowsservercore ####### PORTS ######## #Main rabbitmq port EXPOSE 5672 #port mapper daemon (epmd) EXPOSE 4369 net_dist_listen EXPOSE 35197 #rabbitmq management console EXPOSE 15672 #set the home directory for erlang so rabbit can find it easily ENV ERLANG_HOME “c:\program files\erl8.2\erts-8.2” ENV ERLANG_SERVICE_MANAGER_PATH “c:\program files\erl8.2\erts-8.2” #install chocolatey RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘ https://chocolatey.org/install.ps1 ‘))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin” #install rabbitmq RUN choco install -y rabbitmq #set up the path to the config file ENV RABBITMQ_CONFIG_FILE “C:\rabbitmq” #copy a config file over COPY [“rabbitmq.config”,” C:/”] #set the startup command to be rabbit CMD [“C:/Program Files/RabbitMQ Server/rabbitmq_server-3.6.5/sbin/rabbitmq-server.bat”]