Background
Break News
How to add local font to Tailwind Css and NextJS? - Tutorial Design Pattern? - Blockchain Technology, How to create own Bitcoin virtual currency - Zustand mordern management state - Design Pattern - Flyweight Pattern? - Docker Full training Topic

[Tips] How to use Docker Compose to set up a RabbitMQ service

Monday 31 July 2023
|
Read: Completed in minutes

[Tips] How to use Docker Compose to set up a RabbitMQ service

RabbitMQ is a popular open-source message broker that allows applications to communicate with each other asynchronously. It supports various protocols and platforms, and can be easily scaled and integrated with other services.

One of the challenges of using RabbitMQ is setting up and configuring the service, especially in a distributed environment. Fortunately, Docker Compose can help simplify this process by allowing you to define and run multiple containers as a single service.

Docker Compose is a tool that lets you create and manage multi-container applications using YAML files. You can specify the configuration, dependencies, networks, volumes, and other options for each container in a single file, and then use a single command to start or stop the service.

In this article, we will show you how to use Docker Compose to set up a RabbitMQ service with a web-based management interface. We will also demonstrate how to send and receive messages using Python clients


Step 1: Create a Docker Compose file RabbitMQ

The first step is to create a Docker Compose file that defines the RabbitMQ service. Create a new folder for your project and open it in your text editor. Then, create a file named docker-compose.yml and paste the following content:



        
version: '3' 
services:
  rabbitmq:
    image: rabbitmq
    restart: always
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_DEFAULT_USER: myuser
      RABBITMQ_DEFAULT_PASS: mypassword 
 


This file defines a service named rabbitmq that uses the official rabbitmq image from Docker Hub. This image contains the RabbitMQ server and the web-based management plugin, which allows you to monitor and manage the service from your browser.

The ports section maps the ports 5672 and 15672 from the container to the host machine. Port 5672 is used for communication between RabbitMQ clients and servers, while port 15672 is used for accessing the management interface.

The environment section sets the default username and password for the RabbitMQ service to admin. You can change these values if you want, but make sure to update them in your clients as well.

Step 2: Start the RabbitMQ service

To start the RabbitMQ service, open a terminal window in your project folder and run the following command

docker-compose up --build -d

This command will pull the image from Docker Hub if it is not already present on your machine, create a container from it, and start it in detached mode. You can check the status of the service by running:

docker-compose ps

You should see something like this:

        
Name                Command               State               Ports             
---------------------------------------------------------------------------------
rabbitmq   docker-entrypoint.sh rabbi ...   Up      0.0.0.0:15672->15672/tcp,:::15672->15672/tcp, 25672/tcp, 0.0.0.0:5672->5672/tcp,:::5672->5672/tcp, 4369/tcp


Step 3: Access the RabbitMQ management interface

To access the management interface, open your browser and go to https://localhost:15672/. You should see a login page like this:
How to use Docker Compose to set up a RabbitMQ service

Enter the username and password that you specified in the Docker Compose file (admin/******* by default) and click on Login. You should see a dashboard like this:

How to use Docker Compose to set up a RabbitMQ service - Webzone Tech Tips Zidane



From here, you can view various metrics and statistics about your RabbitMQ service, such as connections, channels, queues, exchanges, messages, etc. You can also perform various actions such as creating or deleting queues, exchanges, bindings, users, etc.
Thank you for reading this post. I hope you found it helpful and easy to follow. If you have any feedback or questions about How to use Docker Compose to set up a RabbitMQ service , please share them in the comments below. I would love to hear from you and discuss this topic further
✋✋✋✋  Webzone Tech Tips, all things Tech Tips for web development  - I am Zidane, See you next time soon ✋✋✋✋

🙇🏼🙇🏼 We Appreciate Your Comments and Suggestions - Webzone, all things Tech Tips web development
Popular Webzone Tech Tips topic maybe you will be like it - by Webzone Tech Tips - Zidane
As a student, I found Blogspot very useful when I joined in 2014. I have been a developer for years . To give back and share what I learned, I started Webzone, a blog with tech tips. You can also search for tech tips zidane on Google and find my helpful posts. Love you all,

I am glad you visited my blog. I hope you find it useful for learning tech tips and webzone tricks. If you have any technical issues, feel free to browse my posts and see if they can help you solve them. You can also leave a comment or contact me if you need more assistance. Here is my blog address: https://learn-tech-tips.blogspot.com.

My blog where I share my passion for web development, webzone design, and tech tips. You will find tutorials on how to build websites from scratch, using hot trends frameworks like nestjs, nextjs, cakephp, devops, docker, and more. You will also learn how to fix common bugs on development, like a mini stackoverflow. Plus, you will discover how to easily learn programming languages such as PHP (CAKEPHP, LARAVEL), C#, C++, Web(HTML, CSS, javascript), and other useful things like Office (Excel, Photoshop). I hope you enjoy my blog and find it helpful for your projects. :)

Thanks and Best Regards!
Follow me on Tiktok @learntechtips and send me a direct message. I will be happy to chat with you.
Webzone - Zidane (huuvi168@gmail.com)
I'm developer, I like code, I like to learn new technology and want to be friend with people for learn each other
I'm a developer who loves coding, learning new technologies, and making friends with people who share the same passion. I have been a full stack developer since 2015, with more than years of experience in web development.
Copyright @2022(November) Version 1.0.0 - By Webzone, all things Tech Tips for Web Development Zidane
https://learn-tech-tips.blogspot.com