RabbitMQ is a message broker that enables applications to communicate with each other and exchange information. It implements AMQP messaging protocol. RabbitMQ is an open-source project that is written by using Erlang programming language.
This tutorial explains how to install RabbitMQ inside a Docker container in the Linux. Commands have been tested on Ubuntu.
Prepare environment
Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.
Install RabbitMQ
- Host network
Run the following command to create a container for RabbitMQ that uses host network:
docker run -d --name=rabbitmq --restart=always --network=host \
-v /opt/rabbitmq:/var/lib/rabbitmq \
rabbitmq:management
- User-defined bridge network
User-defined bridge network can be used for listening on different port. By default, RabbitMQ web service is listening on port 15672. Client connections are listening on port 5672. Both ports can be changed with -p
option.
docker network create app-net
docker run -d --name=rabbitmq --restart=always --network=app-net \
-p 8080:15672 -p 8081:5672 \
-v /opt/rabbitmq:/var/lib/rabbitmq \
rabbitmq:management
Note: it might take a while before initialization is finished and the Docker container starts to respond to requests.
Testing RabbitMQ
Open a web browser and go to http://<IP_ADDRESS>:15672
, where <IP_ADDRESS>
is the IP address of the system. Log in to the dashboard with the default username (guest
) and password (guest
).
Uninstall RabbitMQ
To completely remove RabbitMQ, remove its container:
docker rm --force rabbitmq
Remove RabbitMQ image:
docker rmi rabbitmq:management
You can also remove RabbitMQ data:
sudo rm -rf /opt/rabbitmq
If a user-defined bridge network was created, you can delete it as follows:
docker network rm app-net
Leave a Comment
Cancel reply