RabbitMQ is an open source message broker software that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover. Client libraries to interface with the broker are available for all major programming languages.
docker run --name rabbitmq bitnami/rabbitmq:latest
rabbitmq:
image: bitnami/rabbitmq:latest
WARNING: This is a beta configuration, currently unsupported.
Get the raw URL pointing to the kubernetes.yml manifest and use kubectl to create the resources on your Kubernetes cluster like so:
$ kubectl create -f https://raw.githubusercontent.com/bitnami/bitnami-docker-rabbitmq/master/kubernetes.yml
- Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our automated systems.
- With Bitnami images the latest bug fixes and features are available as soon as possible.
- Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
- Bitnami images are built on CircleCI and automatically pushed to the Docker Hub.
- All our images are based on minideb a minimalist Debian based container image which gives you a small base container image and the familiarity of a leading linux distribution.
The recommended way to get the Bitnami RabbitMQ Docker Image is to pull the prebuilt image from the Docker Hub Registry.
docker pull bitnami/rabbitmq:latest
To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry.
docker pull bitnami/rabbitmq:[TAG]
If you wish, you can also build the image yourself.
docker build -t bitnami/rabbitmq:latest https://github.com/bitnami/bitnami-docker-rabbitmq.git
If you remove every container and volume all your data will be lost, and the next time you run the image the application will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed. If you are using docker-compose your data will be persistent as long as you don't remove rabbitmq*_data
data volumes. If you have run the containers manually or you want to mount the folders with persistent data in your host follow the next steps:
Note: If you have already started using your application, follow the steps on backing up to pull the data from your running container down to your host.
The image exposes a volume at /bitnami/rabbitmq for the RabbitMQ data and configurations. For persistence you can mount a directory at this location from your host. If the mounted directory is empty, it will be initialized on the first run.
docker run -v /path/to/rabbitmq-persistence:/bitnami/rabbitmq bitnami/rabbitmq:latest
or using Docker Compose:
rabbitmq:
image: bitnami/rabbitmq:latest
volumes:
- /path/to/rabbitmq-persistence:/bitnami/rabbitmq
Using Docker container networking, a RabbitMQ server running inside a container can easily be accessed by your application containers.
Containers attached to the same network can communicate with each other using the container name as the hostname.
In this example, we will create a RabbitMQ client instance that will connect to the server instance that is running on the same docker network as the client.
$ docker network create app-tier --driver bridge
Use the --network app-tier
argument to the docker run
command to attach the RabbitMQ container to the app-tier
network.
$ docker run -d --name rabbitmq-server \
--network app-tier \
bitnami/rabbitmq:latest
Finally we create a new container instance to launch the RabbitMQ client and connect to the server created in the previous step:
$ docker run -it --rm \
--network app-tier \
bitnami/rabbitmq:latest rabbitmqctl -n rabbit@rabbitmq-server status
When not specified, Docker Compose automatically sets up a new network and attaches all deployed services to that network. However, we will explicitly define a new bridge
network named app-tier
. In this example we assume that you want to connect to the RabbitMQ server from your own custom application image which is identified in the following snippet by the service name myapp
.
version: '2'
networks:
app-tier:
driver: bridge
services:
rabbitmq:
image: 'bitnami/rabbitmq:latest'
networks:
- app-tier
myapp:
image: 'YOUR_APPLICATION_IMAGE'
networks:
- app-tier
IMPORTANT:
- Please update the YOUR_APPLICATION_IMAGE_ placeholder in the above snippet with your application image
- In your application container, use the hostname
rabbitmq
to connect to the RabbitMQ server
Launch the containers using:
$ docker-compose up -d
When you start the rabbitmq image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose file or on the docker run command line. If you want to add a new environment variable:
- For docker-compose add the variable name and value under the application section:
rabbitmq:
image: bitnami/rabbitmq:latest
ports:
- 15672:15672
environment:
- RABBITMQ_PASSWORD=my_password
- For manual execution add a
-e
option with each variable and value.
Available variables:
RABBITMQ_USERNAME
: RabbitMQ application username. Default: userRABBITMQ_PASSWORD
: RabbitMQ application password. Default: bitnamiRABBITMQ_VHOST
: RabbitMQ application vhost. Default: /RABBITMQ_ERLANG_COOKIE
: Erlang cookie to determine whether different nodes are allowed to communicate with each other.RABBITMQ_NODE_TYPE
: Node Type. Valid values: stats, queue-ram or queue-disc. Default: statsRABBITMQ_NODE_NAME
: Node name and host. E.g.: node@hostname or node (localhost won't work in cluster topology). Default rabbit@localhostRABBITMQ_NODE_PORT_NUMBER
: Node port. Default: 5672RABBITMQ_CLUSTER_NODE_NAME
: Node name to cluster with. E.g.: clusternode@hostnameRABBITMQ_MANAGER_PORT_NUMBER
: Manager port. Default: 15672
This is the simplest way to run RabbitMQ with clustering configuration:
Copy the snippet below into your docker-compose.yml to add a RabbitMQ stats node to your cluster configuration.
version: '2'
services:
stats:
image: bitnami/rabbitmq
environment:
- RABBITMQ_NODE_TYPE=stats
- RABBITMQ_NODE_NAME=rabbit@stats
- RABBITMQ_ERLANG_COOKIE=s3cr3tc00ki3
ports:
- '15672:15672'
volumes:
- 'rabbitmqstats_data:/bitnami/rabbitmq'
Note: The name of the service (stats) is important so that a node could resolve the hostname to cluster with. (Note that the node name is
rabbit@stats
)
Update the definitions for nodes you want your RabbitMQ stats node cluster with.
queue-disc1:
image: bitnami/rabbitmq
environment:
- RABBITMQ_NODE_TYPE=queue-disc
- RABBITMQ_NODE_NAME=rabbit@queue-disc1
- RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
- RABBITMQ_ERLANG_COOKIE=s3cr3tc00ki3
volumes:
- 'rabbitmqdisc1_data:/bitnami/rabbitmq'
Note: Again, the name of the service (queue-disc1) is important so that each node could resolve the hostname of this one.
We are going to add a ram node too:
queue-ram1:
image: bitnami/rabbitmq
environment:
- RABBITMQ_NODE_TYPE=queue-ram
- RABBITMQ_NODE_NAME=rabbit@queue-ram1
- RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
- RABBITMQ_ERLANG_COOKIE=s3cr3tc00ki3
volumes:
- 'rabbitmqram1_data:/bitnami/rabbitmq'
volumes:
rabbitmqstats_data:
driver: local
rabbitmqdisc1_data:
driver: local
rabbitmqram1_data:
driver: local
The docker-compose.yml
will look like this:
version: '2'
services:
stats:
image: bitnami/rabbitmq
environment:
- RABBITMQ_NODE_TYPE=stats
- RABBITMQ_NODE_NAME=rabbit@stats
- RABBITMQ_ERLANG_COOKIE=s3cr3tc00ki3
ports:
- '15672:15672'
volumes:
- 'rabbitmqstats_data:/bitnami/rabbitmq'
queue-disc1:
image: bitnami/rabbitmq
environment:
- RABBITMQ_NODE_TYPE=queue-disc
- RABBITMQ_NODE_NAME=rabbit@queue-disc1
- RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
- RABBITMQ_ERLANG_COOKIE=s3cr3tc00ki3
volumes:
- 'rabbitmqdisc1_data:/bitnami/rabbitmq'
queue-ram1:
image: bitnami/rabbitmq
environment:
- RABBITMQ_NODE_TYPE=queue-ram
- RABBITMQ_NODE_NAME=rabbit@queue-ram1
- RABBITMQ_CLUSTER_NODE_NAME=rabbit@stats
- RABBITMQ_ERLANG_COOKIE=s3cr3tc00ki3
volumes:
- 'rabbitmqram1_data:/bitnami/rabbitmq'
volumes:
rabbitmqstats_data:
driver: local
rabbitmqdisc1_data:
driver: local
rabbitmqram1_data:
driver: local
The image looks for configuration in the conf/
directory of /bitnami/rabbitmq
. As mentioned in Persisting your application you can mount a volume at this location and copy your own configurations in the conf/
directory. The default configuration will be copied to the conf/
directory if it's empty.
The Bitnami RabbitMQ Docker image sends the container logs to the stdout
. To view the logs:
docker logs rabbitmq
or using Docker Compose:
docker-compose logs rabbitmq
You can configure the containers logging driver using the --log-driver
option if you wish to consume the container logs differently. In the default configuration docker uses the json-file
driver.
To backup your data, configuration and logs, follow these simple steps:
docker stop rabbitmq
or using Docker Compose:
docker-compose stop rabbitmq
We need to mount two volumes in a container we will use to create the backup: a directory on your host to store the backup in, and the volumes from the container we just stopped so we can access the data.
docker run --rm -v /path/to/rabbitmq-backups:/backups --volumes-from rabbitmq busybox \
cp -a /bitnami/rabbitmq:latest /backups/latest
or using Docker Compose:
docker run --rm -v /path/to/rabbitmq-backups:/backups --volumes-from `docker-compose ps -q rabbitmq` busybox \
cp -a /bitnami/rabbitmq:latest /backups/latest
Restoring a backup is as simple as mounting the backup as volumes in the container.
docker run -v /path/to/rabbitmq-backups/latest:/bitnami/rabbitmq bitnami/rabbitmq:latest
or using Docker Compose:
rabbitmq:
image: bitnami/rabbitmq:latest
volumes:
- /path/to/rabbitmq-backups/latest:/bitnami/rabbitmq
Bitnami provides up-to-date versions of RabbitMQ, including security patches, soon after they are made upstream. We recommend that you follow these steps to upgrade your container.
docker pull bitnami/rabbitmq:latest
or if you're using Docker Compose, update the value of the image property to
bitnami/rabbitmq:latest
.
Before continuing, you should backup your container's data, configuration and logs.
Follow the steps on creating a backup.
docker rm -v rabbitmq
or using Docker Compose:
docker-compose rm -v rabbitmq
Re-create your container from the new image, restoring your backup if necessary.
docker run --name rabbitmq bitnami/rabbitmq:latest
or using Docker Compose:
docker-compose start rabbitmq
The following parameters have been renamed:
From | To |
---|---|
RABBITMQ_ERLANGCOOKIE |
RABBITMQ_ERLANG_COOKIE |
RABBITMQ_NODETYPE |
RABBITMQ_NODE_TYPE |
RABBITMQ_NODEPORT |
RABBITMQ_NODE_PORT |
RABBITMQ_NODENAME |
RABBITMQ_NODE_NAME |
RABBITMQ_CLUSTERNODENAME |
RABBITMQ_CLUSTER_NODE_NAME |
RABBITMQ_MANAGERPORT |
RABBITMQ_MANAGER_PORT |
We'd love for you to contribute to this container. You can request new features by creating an issue, or submit a pull request with your contribution.
If you encountered a problem running this container, you can file an issue. For us to provide better support, be sure to include the following information in your issue:
- Host OS and version
- Docker version (
docker version
) - Output of
docker info
- Version of this container (
echo $BITNAMI_IMAGE_VERSION
inside the container) - The command you used to run the container, and any relevant output you saw (masking any sensitive information)
Most real time communication happens in the #containers
channel at bitnami-oss.slack.com; you can sign up at slack.oss.bitnami.com.
Discussions are archived at bitnami-oss.slackarchive.io.
Copyright (c) 2017 Bitnami
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.