docker-compose.yml
Example container configuration:
services:
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: rabbitmq
volumes:
- ./.docker/rabbitmq/etc/:/etc/rabbitmq/
- ./.docker/rabbitmq/data/:/var/lib/rabbitmq/
- ./.docker/rabbitmq/logs/:/var/log/rabbitmq/
environment:
RABBITMQ_ERLANG_COOKIE: ${RABBITMQ_ERLANG_COOKIE}
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
ports:
- 5672:5672
- 15672:15672
What does it all mean?
image: rabbitmq:3-management-alpine
Specifies an image to use, in this case the rabbitmq:3-management-alpine
, which is based on the popular Alpine Linux project, and comes with the management plugin installed and enabled by default, which is available on the standard management port of 15672, with the default username and password of guest
/ guest
.
If you'd rather avoid Alpine, you could use rabbitmq:3-management
image, which would increase the image size by around 100 MB.
container_name: rabbitmq
Specifies a custom container name, rather than a generated default name.
volumes:
Mounts host paths or named volumes, specified as sub-options to a service.
In case of the above configuration:
- ./.docker/rabbitmq/etc/:/etc/rabbitmq/
will mount local .docker/rabbitmq/etc/
directory as /etc/rabbitmq/
in the container, allowing easy modification to the configuration files.
- ./.docker/rabbitmq/data/:/var/lib/rabbitmq/
will mount local .docker/rabbitmq/data/
directory as /var/lib/rabbitmq/
in the container, allowing easy local access to RabbitMQ data.
- ./.docker/rabbitmq/logs/:/var/log/rabbitmq/
will mount local .docker/rabbitmq/logs/
directory as /var/log/rabbitmq/
in the container, allowing easy local access to RabbitMQ logs.
If you want to provide your own configuration file instead of using one automatically generated by docker-entrypoint.sh
you might mount your config file as /etc/rabbitmq/rabbitmq.conf
(sysctl format, for RabbitMQ versions 3.7.0 and up) or /etc/rabbitmq/rabbitmq.config
(Erlang term configuration format, for versions prior to 3.7.0).
environment:
RABBITMQ_ERLANG_COOKIE: ${RABBITMQ_ERLANG_COOKIE}
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
Add environment variables, either as an array or a dictionary.
ports:
- 5672:5672
- 15672:15672
Port mapping defined in short syntax: HOST:CONTAINER
.
5672:5672
means that port 5672
on host will forward all its traffic to RabbitMQ's main port 5672
in the container. Same with management plugin's port 15672:15672
.
Note that while you are free to modify host ports to your liking, you should not change container ports unless you change them in the rabbitmq.conf
configuration file too.
.docker/rabbitmq/rabbitmq.conf
Default rabbitmq.conf
configuration file could either be automatically generated by the docker-entrypoint.sh script on container initialization, or we could provide our own, for example:
loopback_users.guest = false
listeners.tcp.default = 5672
default_pass = guest
default_user = guest
hipe_compile = false
management.listener.port = 15672
management.listener.ssl = false
.docker/rabbitmq/enabled_plugins
The rabbitmq:3-management
image (and its -alpine
version too) ships with only one plugin installed by default - management plugin. Once it is enabled, the plugin configuration file /etc/rabbitmq/enabled_plugins
looks as follows:
[rabbitmq_management].
RabbitMQ ships with several Tier 1 (Core) plugins included in the distribution.
Q&A: What are plugin tiers?
Plugins that ship with the RabbitMQ distributions are often referred to as tier 1 plugins. Provided that a standard distribution package is used they do not need to be installed but do need to be enabled before they can be used.
In addition to the plugins bundled with the server, team RabbitMQ offers binary downloads of curated plugins which have been contributed by authors in the community. See the community plugins page for more details.
Even more plugins can be found on GitHub, GitLab, Bitbucket and similar services.
Other community-developed plugins need to be downloaded and installed first before enabling them for RabbitMQ.