docker.recipes

RabbitMQ

intermediate

Message broker with management UI.

Overview

RabbitMQ is a powerful open-source message broker that implements the Advanced Message Queuing Protocol (AMQP) alongside support for MQTT and STOMP protocols. Originally developed by Rabbit Technologies in 2007 and later acquired by VMware, RabbitMQ has become one of the most widely deployed message brokers in enterprise environments. It excels at reliable message delivery, complex routing scenarios, and providing guaranteed message persistence, making it an essential component for distributed systems that require robust asynchronous communication. This configuration deploys RabbitMQ with the management plugin enabled, providing both the core message broker functionality on port 5672 and a comprehensive web-based administration interface on port 15672. The setup uses the Alpine-based image for reduced resource footprint while maintaining full functionality. RabbitMQ handles message routing through exchanges, queues, and bindings, enabling sophisticated messaging patterns like publish/subscribe, request/reply, and work queues with features like message acknowledgments, dead letter queues, and priority handling. This stack is ideal for developers building microservices architectures, DevOps teams implementing reliable task processing systems, and organizations requiring enterprise-grade message routing with operational visibility. Unlike simpler pub/sub systems, RabbitMQ provides message durability, complex routing logic, and clustering capabilities that make it suitable for mission-critical applications where message loss is unacceptable and system reliability is paramount.

Key Features

  • Multiple messaging protocol support including AMQP 0-9-1, MQTT, and STOMP for diverse client compatibility
  • Flexible message routing with exchanges, queues, and binding patterns supporting direct, topic, fanout, and headers routing
  • Management UI with real-time monitoring, queue inspection, message tracing, and administrative controls
  • Message persistence and durability guarantees with configurable storage options and acknowledgment patterns
  • Dead letter queues for handling failed message processing and message TTL management
  • Priority queues enabling message ordering based on application-defined importance levels
  • Plugin ecosystem including federation, shovel, delayed message exchange, and clustering extensions
  • Built-in clustering and high availability features with automatic failover and data replication

Common Use Cases

  • 1Microservices communication requiring reliable message delivery between distributed application components
  • 2Background job processing systems with work queues for handling asynchronous tasks like image processing or email sending
  • 3Event-driven architectures where services need to react to business events with guaranteed delivery
  • 4IoT message routing and processing for device telemetry, commands, and sensor data aggregation
  • 5Enterprise application integration connecting legacy systems with modern cloud-native applications
  • 6E-commerce order processing pipelines requiring coordination between inventory, payment, and fulfillment services
  • 7Real-time notification systems for chat applications, push notifications, and user activity feeds

Prerequisites

  • Minimum 256MB RAM available, with 1GB+ recommended for production workloads with high message throughput
  • Ports 5672 (AMQP) and 15672 (Management UI) available and not conflicting with existing services
  • Environment variables RABBITMQ_USER and RABBITMQ_PASSWORD configured in .env file for authentication
  • Understanding of message queue concepts including exchanges, queues, bindings, and routing keys
  • Basic familiarity with AMQP protocol concepts or willingness to learn message broker fundamentals
  • Docker host with sufficient disk space for message persistence and log storage

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 rabbitmq:
3 image: rabbitmq:3-management-alpine
4 container_name: rabbitmq
5 restart: unless-stopped
6 environment:
7 RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
8 RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
9 volumes:
10 - rabbitmq_data:/var/lib/rabbitmq
11 ports:
12 - "5672:5672"
13 - "15672:15672"
14
15volumes:
16 rabbitmq_data:

.env Template

.env
1RABBITMQ_USER=admin
2RABBITMQ_PASSWORD=changeme

Usage Notes

  1. 1Docs: https://www.rabbitmq.com/documentation.html
  2. 2Management UI at http://localhost:15672, AMQP on port 5672
  3. 3Login with RABBITMQ_USER/RABBITMQ_PASSWORD from env
  4. 4Create exchanges, queues, and bindings via web UI
  5. 5Enable plugins: docker exec rabbitmq rabbitmq-plugins enable <plugin>
  6. 6Common plugins: shovel, federation, delayed_message_exchange

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 rabbitmq:
5 image: rabbitmq:3-management-alpine
6 container_name: rabbitmq
7 restart: unless-stopped
8 environment:
9 RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
10 RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
11 volumes:
12 - rabbitmq_data:/var/lib/rabbitmq
13 ports:
14 - "5672:5672"
15 - "15672:15672"
16
17volumes:
18 rabbitmq_data:
19EOF
20
21# 2. Create the .env file
22cat > .env << 'EOF'
23RABBITMQ_USER=admin
24RABBITMQ_PASSWORD=changeme
25EOF
26
27# 3. Start the services
28docker compose up -d
29
30# 4. View logs
31docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/rabbitmq/run | bash

Troubleshooting

  • Management UI shows 'Connection refused' error: Verify port 15672 is not blocked by firewall and container is fully started (check logs for 'Server startup complete')
  • AMQP connections failing with authentication errors: Confirm RABBITMQ_USER and RABBITMQ_PASSWORD environment variables are properly set and container has been restarted
  • High memory usage warnings in logs: Increase Docker memory limits or configure RabbitMQ memory watermarks using RABBITMQ_VM_MEMORY_HIGH_WATERMARK environment variable
  • Messages not routing between queues: Check exchange types and binding keys in management UI - ensure routing keys match binding patterns exactly
  • RabbitMQ node fails to start after restart: Verify rabbitmq_data volume permissions and check if previous shutdown was clean (look for 'Erlang distribution on node stopped' in logs)
  • Plugin activation fails with permission errors: Use docker exec rabbitmq rabbitmq-plugins enable <plugin_name> and ensure container has write access to configuration directories

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space