How to Run RabbitMQ in a Docker Container?

This tutorial will teach you how to run RabbitMQ in a Docker container. If you do not use Docker, you can download RabbitMQ Server to your computer.

To learn more about Docker, please check Docker Tutorials page.

Run RabbitMQ Using Image from Docker Hub

RabbitMQ docker image is available on Docker Hub. If you have Docker installed on your machine, you can easily run the RabbitMQ docker container using the following command:

docker run -d -p 15672:15672 -p 5672:5672 -p 5671:5671 --hostname my-rabbitmq --name my-rabbitmq-container rabbitmq:3-management

where:

  • –hostname is a custom RabbitMQ host name you want to use on your computer. You can use this hostname when referring to this RabbitMQ container on your local computer.
  • –name – is a meaningful name for the container. This name will be displayed when using Docker’s ps command. It is helpful to see meaningful names when we list our containers later.  
  • -p 15672:15672  –  is a port mapping where  <local computer port>:<docker container port> 

What If You Have Docker Image on Docker Hub?

If you have a RabbitMQ Docker image in your private Docker Hub repository, then you can run it the following way:

docker run -d --name rabbit-name-management -p 15672:15672 -p 5672:5672 -p 5671:5671 skargopolov/rabbitmq:3-management

Where

  • –name is a meaningful name for the container. 
  • skargopolov/rabbitmq:3-managementis a <Docker Hub username>/<Docker Hub Repository name>:<tag>
  • -p  15672:15672  –  is port mapping where  <local computer port>:<docker container port>

To learn more about Docker, check the below list of online video courses that teach Docker.


Leave a Reply

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