Skip to content

Instantly share code, notes, and snippets.

@Zerpet
Created April 6, 2018 10:14
Show Gist options
  • Save Zerpet/ea57b8f06f756cfb9191cbf2891beb37 to your computer and use it in GitHub Desktop.
Save Zerpet/ea57b8f06f756cfb9191cbf2891beb37 to your computer and use it in GitHub Desktop.
How to get a cluster of RabbitMQ using Docker

In just 5 minutes

You will need the following tools:

  • curl or wget
  • docker-compose

Blazing fast version

curl https://raw.githubusercontent.com/Zerpet/docker-rabbitmq-cluster/version/3.6/compose-templates/3-disc-nodes.yml > docker-compose.yml
docker-compose -p blazing-fast-rabbit up -d

That was so fast we have 4 minutes left! 🐇

# Interactive terminal
docker-compose -p blazing-fast-rabbit exec rabbitmq-server1 /bin/bash

# Any rabbitmqctl command
docker-compose -p blazing-fast-rabbit exec rabbitmq-server1 rabbitmqctl report

Ok, we had fun. Now it's time to clean up before we go.

docker-compose -p blazing-fast-rabbit down

What just happened?

  • We used curl to download a Docker Compose template for RabbitMQ 3.6 from the image repo
  • We started a new Docker Compose "project" named blazing-fast-rabbit using the template
  • The Docker image has an automated procedure in the entry script to automatically join a RabbiMQ cluster
  • The management UI ports are exposed and forwarded to localhost ports 15672, 15673 and 15674
  • We can get an interactive Bash terminal to the container
  • We can execute any command in the container without an interactive terminal!
  • We left everything as we found it

The last step is a destructive action. If you wish to reuse the cluster at a later time, you can use stop/start commands in compose.

docker-compose -p blazing-fast-rabbit stop
docker-compose -p blazing-fast-rabbit start

Caveats

  • The YAML file docker-compose.yml must be in the current directory
    • Otherwise, we have to specify the path using the option -f
  • The image has some not fun limitations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment