Dockerize RabbitMQ

You want to run RabbitMQ in a Docker environment? You want MQTT and a nice web interface for administration?

Just use the Dockerfile and the hints in this post to get your server up and running in no time!

Beware: There are two very important points to keep in mind! If you miss even one of these steps, you will loose your configuration and users on every restart!

Use a persistent volume

Map the path /var/lib/rabbitmq to a Volume. Either a Docker Volume or a volume mapping to the host will do the trick.

See Docker Guide: volumes for more information about Volumes.

Set a hostname

RabbitMQ will use the hostname as part of its database and configuration files. Docker will set a random hostname on each startup.

So make sure you use the -h <hostname> option when starting the container.

 

Example

Build the container by putting the above contents into a file called Dockerfile and run the command  docker build -t myrabbitmq - < Dockerfile . This will build a container named “myrabbitmq“.

Now as we have the Container in place, we can startup the container executing the following command

 

If everything is correct, the container should be started and you should be able to connect to http://localhost:15672/ with your web browser (User/Password is guest).

rabbitmq admin web

  • Mangesh Paranjape

    I am trying to install RabbitMQ following this post. somehow I am not able to connect to management plugin from ec2 dns name. I have opened port 15672 from security group. I think I am missing something in host mapping. Any idea?