Member-only story
Get Started with RabbitMQ on Docker
How to quickly spin up RabbitMQ instances with Docker and Docker Compose.

RabbitMQ (link) is the most widely-deployed open source message broker. A message broker is a computer program module that exchanges messages between the message producers and consumers, thus is able to effectively decouple different software components. RabbitMQ is lightweight and easy to deploy on premises and in the cloud. Moreover, its official tutorials are extremely easy to follow.
In this article, we will talk about how to quickly spin up RabbitMQ instances on Docker. We will go through two ways to run a RabbitMQ Docker image in a container: (1) using the docker run
command; (2) using Docker Compose. Getting familiar with these two approaches should greatly accelerate your learning on RabbitMQ.
I will not talk about any RabbitMQ client code here, because the official tutorials have already done an awesome job in explaining code details in different scenarios. For your information, the demos in this article are written in .NET (should be transferable to other languages), and the complete code can be found in my GitHub repository.
Now let’s dive into the world of RabbitMQ and Docker.
Using the RabbitMQ Docker Image
The RabbitMQ container registry (link) includes a variety of images for different platforms. In this article, we will use the RabbitMQ image with a tag 3-management
, which is a Docker image with the RabbitMQ management plugin installed and enabled by default.
Assuming the Docker Desktop has been installed, we use the command docker pull rabbitmq:3-management
to pull a RabbitMQ Docker image from DockerHub. After the Docker image is downloaded and saved locally, we can start a RabbitMQ container using the following command.
In the command above, the port 5672 is used for the RabbitMQ client connections, and the port 15672 is for the RabbitMQ management website. This…