Base docker image to run a RabbitMQ server
To create the image lastbackend/rabbitmq, execute the following command on the lb-docker-rabbitmq folder:
docker build -t lastbackend/rabbitmq .
Run the following command to start rabbitmq:
docker run -d -p 5672:5672 -p 15672:15672 lastbackend/rabbitmq
The first time that you run your container, a new random password will be set. To get the password, check the logs of the container by running:
docker logs <CONTAINER_ID>
You will see an output like the following:
---------------------------------------- RabbitMQ ---------------------------------------
+-++-+ curl --user admin:sJZmFTlDejb9sjiDstPHKezJ http://«host»:«port»/api/vhosts"
| LB |
+-++-+ Please remember to change the above password!
-----------------------------------------------------------------------------------------
In this case, sJZmFTlDejb9sjiDstPHKezJ is the password set.
You can then connect to RabbitMQ:
curl --user admin:sJZmFTlDejb9sjiDstPHKezJ http://<host>:<port>/api/vhosts
If you want to use a preset password instead of a randomly generated one, you can
set the environment variable PASS to your specific password when running the container:
---------------------------------------- RabbitMQ ---------------------------------------
+-++-+
| LB | curl --user admin:«password» http://«host»:«port»/api/vhosts"
+-++-+
-----------------------------------------------------------------------------------------
docker run -d -p 5672:5672 -p 15672:15672 -e PASS="mypass" lastbackend/rabbitmq
You can now test your new admin password:
curl --user admin:mypass http://<host>:<port>/api/vhosts
To run a cluster with all the DNS-Reachable Host, you have to set RABBITMQ_USE_LONGNAME and HOSTNAME on first server :
docker run -d \
-p 5672:5672 -p 15672:15672 -p 35197:35197 -p 4369:4369 -p 25672:25672 \
-e HOSTNAME=node1.host.io \
-e RABBITMQ_USE_LONGNAME=true \
lastbackend/rabbitmq
And add CLUSTER_WITH for the others nodes :
docker run -d \
-p 5672:5672 -p 15672:15672 -p 35197:35197 -p 4369:4369 -p 25672:25672 \
-e HOSTNAME=node2.host.io \
-e RABBITMQ_USE_LONGNAME=true \
-e CLUSTER_WITH=node1.host.io \
lastbackend/rabbitmq
Content type
Image
Digest
sha256:04f653d72…
Size
87.9 MB
Last updated
almost 11 years ago
docker pull lastbackend/rabbitmq