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!
# use rabbitmq official
# enable management plugin
RUN rabbitmq-plugins enable --offline rabbitmq_management
# enable mqtt plugin
RUN rabbitmq-plugins enable --offline rabbitmq_mqtt
# expose management port
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.
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
docker run -it -h rabbitmqhost -p 1883:1883 -p 15672:15672 -v /opt/rabbitmq:/var/lib/rabbitmq myrabbitmq
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).