Setting up RabbitMQ in Docker using Docker compose.


Recently I have been working on an application containing serval microservices. These microservices used RabbitMQ for communication between them. In order to develop this application I installed RabbitMQ on my machine as well as Erlang. This was not as easy as I thought it would be, it took me half a day to get it all working.

I am a Free Lance software developer and when I leave this contract I wanted my clients developers to be able to support this application. I was worried they would have to go though the struggles i went though while installing Erlang and RabbitMQ on Their windows machines.

The project itself was going to be running in AKS so everything on the server would be in containers anyways. Why not install RabbitMQ on my machine in Docker. My client’s developers were familiar with docker already. Why not create them a docker compose file which will set up everything for them. It has also occurred to me that they may invite me that they may call me back to make changes in the coming years. Future Linda will appreciate my doing this for her.

What is docker compose?

Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. 

So by creating a docker compose file I can configure not only RabbitMQ but the RabbitMQ management UI and open any ports I need to.

Installing RabbitMQ in Docker

To add RabbitMQ to Docker i would run the following commands

#This creates rabbit and opens the port.

docker run -d --hostname my-rabbit --name some-rabbit -p 5672:5672 -p 8080:15672 rabbitmq:3

# Creates the RabbitMQ UI management and opens to port 9000   Then you can do http://localhost:9000/#/ to see rabbit working.
docker run -d --hostname my-rabbit --name some-rabbit-management -p 9000:15672 rabbitmq:3-management

Now running those commands really isn’t that hard, but there is an easer way of doing this.

Creating docker-compose.yaml

In the docker-compose.yaml we tell it what docker image we would like to use. Give our container a name, and configure the ports.

        image: rabbitmq:3-management
        container_name: rabbitmq
            - 5672:5672
            - 15672:15672

Running docker-compose.yaml

To run the docker compose file we only need to run the following command.

docker-compose up

This will install RabbitMQ and the ManagmentUI in docker and open it to the preconfigured standard RabbitMQ ports.

How to stop RabbitMQ

To stop the container you can then run

docker-compose down

This will cause the container to then stop running.


It is a very good idea to set up your development environment. Things like RabbitMQ, or your database are external services that your application will need to run. In the past all of these things had to be installed and configured before you can even begin working on your application.

Now a lot of these external applications can run in Docker. Setting up Docker compose to configure your development environment can make your life a lot easer. If in serval months you need to go back to this application you will be able to run the docker compose file and know that your development environment will be configured for you.

About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.