Skip to content

Instantly share code, notes, and snippets.

@ashabhasa
Last active June 4, 2018 14:26
Show Gist options
  • Save ashabhasa/0722b862ca9a3dd1ee03d5abcf8b152d to your computer and use it in GitHub Desktop.
Save ashabhasa/0722b862ca9a3dd1ee03d5abcf8b152d to your computer and use it in GitHub Desktop.
Create rabbitmq image that also creates users and vhosts
FROM rabbitmq:3-management
# The script was first published here http://mpas.github.io/blog/2015/06/11/setting-up-docker-rabbitmq-with-predefined-users/vhosts/
# Add script to create default users / vhosts
ADD init.sh /init.sh
# Set correct executable permissions
RUN chmod +x /init.sh
# Define default command
CMD ["/init.sh"]
@ashabhasa
Copy link
Author

Find the init.sh file here

@ashabhasa
Copy link
Author

Place both files in the same directory and build the image as follows

$ docker build -t my_rabbitmq_image .

then start the container

$ docker run -d --rm=true --name [rabbit-container-name] -p 5672:5672 -p 15672:15672  my_rabbitmq_image

or

$ docker run -d  -p 5672:5672 -p 15672:15672 --name [rabbit-container-name] my_rabbitmq_image

@ashabhasa
Copy link
Author

example: docker run -d --rm=true --name local-rabbit -p 5672:5672 -p 15672:15672 my_rabbitmq_image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment