Effective Docker Setup for RabbitMQ

Select the official image from the registry based on system preferences. Two common variations include standard Ubuntu and minimal Alpine builds.

Retrieving the Image

docker pull rabbitmq:3.9.10-management

Executing the Instance

Launch the service in the background with persistent restart policies. Ensure exposure of ports 5672 (AMQP), 15672 (Management), and 25672 (Cluster/EPMD).

docker run -d \
  --restart=always \
  -p 5672:5672 \
  -p 15672:15672 \
  -p 25672:25672 \
  --name mq-core \
  rabbitmq:3.9.10-management

Once active, navigate to http://<host_ip>:15672 in a browser. Initial access credentials are typically guest for both user and password fields.

Runtime Configuration

Customize volume mappings for data persistence and define environment variables for initial users and virtual hosts.

docker run -d \
  --name rm-prod \
  -p 15672:15672 \
  -p 5672:5672 \
  -v /srv/rabbitmq/logs:/var/log/rabbitmq \
  -v /srv/rabbitmq/data:/var/lib/rabbitmq \
  --hostname app-server \
  -e RABBITMQ_DEFAULT_VHOST=default_db \
  -e RABBITMQ_DEFAULT_USER=app_user \
  -e RABBITMQ_DEFAULT_PASS=SecureString99 \
  rabbitmq:3.9.10-management

Important options include:

  • -v: Persist message data by linking host folders to container volumes.
  • --hostname: Sets the Erlang node name critical for clustering.
  • -e: Configures default authentication and vhost settings.

Management via CLI

Execute administrative tasks using rabbitmqadmin from the host side.

# Declare a Direct Exchange
docker exec -it rm-prod rabbitmqadmin declare exchange name=log-proc type=direct durable=true

# Create a Destination Queue
docker exec -it rm-prod rabbitmqadmin declare queue name=log-store

# Bind the Connection
docker exec -it rm-prod rabbitmqadmin declare binding source=log-proc destination=log-store routing_key=error_msg

Shell Access and Settings

Open a interactive terminal session inside the container for file editing.

docker exec -it rm-prod bash

Configuration adjustments are made in /etc/rabbitmq/rabbitmq.conf. Specifically, changing loopback_users to none enables the guest account to connect from remote clients.

loopback_users.guest = none

Tags: docker RabbitMQ messaging devops

Posted on Thu, 30 Jul 2026 16:15:08 +0000 by libertyct