Deploy RabbitMQ with Docker Compose: Step‑by‑Step Guide & Best Practices
This article walks through installing RabbitMQ 3.12.6‑management via Docker‑Compose V2, covering image selection, configuration details, plugin setup for delayed messages, common pitfalls, and .NET client connection examples, providing practical tips for reliable messaging in backend systems.
Preface
RabbitMQ is a powerful open‑source message‑queue system that provides efficient message communication and asynchronous processing. This article mainly introduces its deployment and installation based on Docker‑Compose and shares some usage experiences.
Features
Mature and stable
Message persistence
Flexible routing
High performance, high availability, strong scalability
Plugin system (management UI, message tracing, transformation, etc.)
Official .NET/Java SDKs
Use Cases
Logging, message sending, data synchronization in projects – stable and reliable
Asynchronous processing for module initialization and data import
Idempotent handling with different acknowledgment strategies to prevent duplicate consumption
Delayed messages via the delayed‑message plugin (limited to a few seconds, minutes, hours, or at most a couple of days)
.NET SDK: RabbitMQ.Client (to be wrapped and shared later)
Practice
Install RabbitMQ v3.12.6‑management using Docker Compose V2.
Preparation
Current version: v3.12.6
Image: rabbitmq:3.12.6-management (includes web management UI)
Default ports: 5672 (application), 15672 (web UI)
Docker Compose Installation
This article assumes Docker V24 and Docker Compose V2; refer to previous articles for installation details.
Configuration Details
Fixed image version: rabbitmq:3.12.6-management Hostname: rabbitserver Virtual host: admin_vhost Credentials: user root, password devops666 Ports: 5672 (application) and 15672 (web UI)
Data directory mount: ./data:/var/lib/rabbitmq Additional plugins directory mount: ./myplugins:/myplugins (default container plugin dir is /plugins, not recommended to mount directly)
Set plugin search path: RABBITMQ_PLUGINS_DIR: '/plugins:/myplugins' Network: devopsnetwork (create with docker network create devopsnetwork)
compose.yml File
Copy the prepared compose.yml to the server.
Run docker compose up -d to start the services.
version: '3.1'
services:
rabbitmq:
image: rabbitmq:3.12.6-management
container_name: rabbitmq_3_12
restart: always
# Node name rabbit@rabbitserver, otherwise Docker uses container ID
hostname: rabbitserver
environment:
# Default virtual host
RABBITMQ_DEFAULT_VHOST: admin_vhost
# Username
RABBITMQ_DEFAULT_USER: root
# Password
RABBITMQ_DEFAULT_PASS: devops666
# Custom plugin directory
RABBITMQ_PLUGINS_DIR: '/plugins:/myplugins'
ports:
- "5672:5672"
- "15672:15672"
volumes:
- ./data:/var/lib/rabbitmq
- ./myplugins:/myplugins
networks:
- devopsnetwork
networks:
devopsnetwork:
external: trueDeployment Successful
Deployed machine IP: 192.168.123.214
Install Plugin: Delayed Message Plugin
Note: The plugin only supports delay intervals of seconds, minutes, or hours, up to at most a day or two. Original: "This plugin was designed for delaying message publishing for a number of seconds, minutes, or hours. A day or two at most."
Download the plugin file rabbitmq_delayed_message_exchange-3.12.0.ez from the GitHub releases page.
Place the downloaded file into the ./myplugins directory (already mounted into the container).
Enable the plugin inside the container:
docker exec -it rabbitmq_3_12 /bin/bash -c "rabbitmq-plugins enable rabbitmq_delayed_message_exchange"The container will automatically discover the .ez file in /plugins and /myplugins and install it.
After enabling, the plugin appears on the Exchanges page.
Pitfalls
Following the configuration above avoids the listed issues; refer to them if they reappear.
Delayed messages are limited to at most a day or two; longer intervals will not be consumed.
Do not mount the /plugins directory directly; instead use RABBITMQ_PLUGINS_DIR: '/plugins:/myplugins' to specify multiple directories.
Omitting the hostname causes the node name to be the container ID.
Using the rabbitmq:3.x-management image with an empty plugins directory may cause startup errors such as:
{"init terminating in do_boot",{undef,[{rabbit,boot,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}Admin UI errors may require a version upgrade; for example, version 3.9.29-management showed errors that were resolved by switching to 3.12.6-management and refreshing the page.
Before switching versions, clear the /data directory; otherwise the container may fail to start.
If the Exchanges page shows errors after a version change, a simple Ctrl+F5 (hard refresh) and re‑login resolves it.
Usage
.NET SDK
Official client:
RabbitMQ.ClientConnection Configuration
var factory = new ConnectionFactory
{
HostName = "192.168.123.214",
Port = 5672,
VirtualHost = "admin_vhost",
UserName = "root",
Password = "devops666",
};Demo Example
A demo project is built to test the usage; further details on wrapper implementation will be discussed later.
Conclusion
Installation is relatively straightforward once the correct version is chosen; the main challenge lies in selecting the appropriate solution for specific business scenarios. The plugin installation required some experimentation, but the process has been optimized.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
