Docker + RabbitMQ

RabbitMQ is a Message Queue system (hence: MQ). Consider it a message bus, where things can pop messages onto the bus and other things can consume those same messages. The uptick is that as long as something is able to connect to the message bus, it can talk to everything else on that same bus.

First, some pre-setup:

$ echo "[rabbitmq_federation_management,rabbitmq_management,rabbitmq_prometheus,rabbitmq_web_dispatch,rabbitmq_management_agent]." > enabled_plugins

Then:

$ mkdir conf.d

So now we have a file with a list of plugins we’d like enabled, and an empty directory called conf.d. Next, let’s build our docker-compose.yml file:

services:
  rabbitmq:
    image: rabbitmq:latest
    restart: always
    ports:
# MQTT - uncomment next line to use
#      - 1883:1883
      - 5672:5672
      - 15672:15672
      - 15692:15692
# STOMP - uncomment next line to use
#      - 61613:61613
    environment:
      RABBITMQ_DEFAULT_USER: admin
      RABBITMQ_DEFAULT_PASS: password
    volumes:
      - rabbitmq-data:/var/lib/rabbitmq
      - ./enabled_plugins:/etc/rabbitmq/enabled_plugins
      - ./conf.d:/etc/rabbitmq/conf.d

volumes:
  rabbitmq-data:
    external: false

Be sure to update the environment variables RABBITMQ_DEFAULT_USER and RABBITMQ_DEFAULT_PASS to suit your needs – these are the credentials you’ll use to log into the web interface on port 5672, so keep them safe.

This setup uses docker’s built-in volumes for storage, but gives the user an easy way to change the plugins used by the docker container and to tweak other configuration variables.