-
Notifications
You must be signed in to change notification settings - Fork 0
210 RabbitMq in Docker
chempkovsky edited this page Jun 17, 2022
·
8 revisions
- Read the article
- Pull RabbitMq
docker pull rabbitmq
- hostname
docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3
- default user and password
docker run -d --hostname my-rabbit --name some-rabbit -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management
- default vhost
docker run -d --hostname my-rabbit --name some-rabbit -e RABBITMQ_DEFAULT_VHOST=my_vhost rabbitmq:3-management
- Management Plugin
docker run -d --hostname my-rabbit --name some-rabbit rabbitmq:3-management
docker run -d --hostname my-rabbit --name some-rabbit -p 8080:15672 rabbitmq:3-management
- We can export ready-to-use RabbitMq definitions to a file
rabbitmqctl export_definitions C:\tmp\defs.json --format json
- read Definition Import at Node Boot Time
- We can import RabbitMq definitions
- with Docker
COPY
-command - with bind-mount. Read Docker Configs
- with Docker
- Pull RabbitMq
- in the article 045 Install and configure RabbitMq we defined additional virtual host, admin user...
- Our goal is to import these settings into the docker image.
- create a working folder where all files below will be saved
- create
rabbitmq.conf
file with the content as follows
listeners.tcp.default = 5672
management.tcp.port = 15672
load_definitions = /etc/rabbitmq/definitions.json
-
load_definitions=...
is the only line that matters to us
- we have RabbitMq running in the virtual machine
- we used the following command to export settings:
rabbitmqctl export_definitions C:\tmp\definitions.json --format json
- copy
definitions.json
into the working folder
Click to show the file
{
"bindings": [
{
"arguments": {},
"destination": "PhbkDivisionViewExtForLkUpMsg",
"destination_type": "exchange",
"routing_key": "",
"source": "LpPhBkViews.PhBk:IPhbkDivisionViewExtForLkUpMsg",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "PhbkEmployeeViewExtForLkUpMsg",
"destination_type": "exchange",
"routing_key": "",
"source": "LpPhBkViews.PhBk:IPhbkEmployeeViewExtForLkUpMsg",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "PhbkPhoneViewExtForLkUpMsg",
"destination_type": "exchange",
"routing_key": "",
"source": "LpPhBkViews.PhBk:IPhbkPhoneViewExtForLkUpMsg",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "MassTransit:Fault",
"destination_type": "exchange",
"routing_key": "",
"source": "MassTransit:Fault--LpPhBkViews.PhBk:IPhbkDivisionViewExtForLkUpMsg--",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "PhbkDivisionViewExtForLkUpMsg",
"destination_type": "queue",
"routing_key": "",
"source": "PhbkDivisionViewExtForLkUpMsg",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "PhbkDivisionViewExtForLkUpMsg_error",
"destination_type": "queue",
"routing_key": "",
"source": "PhbkDivisionViewExtForLkUpMsg_error",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "PhbkEmployeeViewExtForLkUpMsg",
"destination_type": "queue",
"routing_key": "",
"source": "PhbkEmployeeViewExtForLkUpMsg",
"vhost": "phbkhost"
},
{
"arguments": {},
"destination": "PhbkPhoneViewExtForLkUpMsg",
"destination_type": "queue",
"routing_key": "",
"source": "PhbkPhoneViewExtForLkUpMsg",
"vhost": "phbkhost"
}
],
"exchanges": [
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "MassTransit:Fault--LpPhBkViews.PhBk:IPhbkDivisionViewExtForLkUpMsg--",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "LpPhBkViews.PhBk:IPhbkDivisionViewExtForLkUpMsg",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkDivisionViewExtForLkUpMsg",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkPhoneViewExtForLkUpMsg",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkEmployeeViewExtForLkUpMsg",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "LpPhBkViews.PhBk:IPhbkEmployeeViewExtForLkUpMsg",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkDivisionViewExtForLkUpMsg_error",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "LpPhBkViews.PhBk:IPhbkPhoneViewExtForLkUpMsg",
"type": "fanout",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "MassTransit:Fault",
"type": "fanout",
"vhost": "phbkhost"
}
],
"global_parameters": [],
"parameters": [
{
"component": "vhost-limits",
"name": "limits",
"value": {
"max-connections": 25,
"max-queues": 30
},
"vhost": "phbkhost"
}
],
"permissions": [
{
"configure": ".*",
"read": ".*",
"user": "admin",
"vhost": "phbkhost",
"write": ".*"
},
{
"configure": ".*",
"read": ".*",
"user": "guest",
"vhost": "/",
"write": ".*"
},
{
"configure": ".*",
"read": ".*",
"user": "admin",
"vhost": "/",
"write": ".*"
}
],
"policies": [],
"queues": [
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkDivisionViewExtForLkUpMsg_error",
"type": "classic",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkPhoneViewExtForLkUpMsg",
"type": "classic",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkDivisionViewExtForLkUpMsg",
"type": "classic",
"vhost": "phbkhost"
},
{
"arguments": {},
"auto_delete": false,
"durable": true,
"name": "PhbkEmployeeViewExtForLkUpMsg",
"type": "classic",
"vhost": "phbkhost"
}
],
"topic_permissions": [
{
"exchange": ".*",
"read": ".*",
"user": "admin",
"vhost": "phbkhost",
"write": ".*"
},
{
"exchange": ".*",
"read": ".*",
"user": "admin",
"vhost": "/",
"write": ".*"
}
],
"users": [
{
"hashing_algorithm": "rabbit_password_hashing_sha256",
"limits": {},
"name": "admin",
"password_hash": "ZKjNeIhvkK4QBuXcxpg+Yqbn1uTC7v05vQdbFucKr2IPKnQu",
"tags": [
"administrator"
]
},
{
"hashing_algorithm": "rabbit_password_hashing_sha256",
"limits": {},
"name": "guest",
"password_hash": "yYaWG9CVi8L74A2bXjfEdLbst5QCvmNrjrsojt1HyKZcCnz9",
"tags": [
"administrator"
]
}
],
"vhosts": [
{
"limits": [],
"metadata": {
"description": "Default virtual host",
"tags": []
},
"name": "/"
},
{
"limits": [
[
"max-connections",
25
],
[
"max-queues",
30
]
],
"metadata": {
"description": "",
"tags": []
},
"name": "phbkhost"
}
]
}
- create
Dockerfile
file with the content as follows
FROM rabbitmq:3-management
COPY definitions.json /etc/rabbitmq/definitions.json
COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
- create
Docker-compose.yml
file with the content as follows
version: '3.9'
services:
rabbit:
build: .
hostname: my-rabbit
container_name: 'rabbitmq'
environment:
RABBITMQ_CONFIG_FILE: '/etc/rabbitmq/rabbitmq.conf'
ports:
- 5672:5672
- 15672:15672
- run the command
docker-compose -f "docker-compose.yml" up -d --build
-
Docker control panel (Docker Desktop for Windows) stops working after starting a service
- Docker command line tool works!
-
We took the same issue with Docker-compose.yml as follows
- with
image: rabbitmq:3-management
- with
version: '3.9'
services:
rabbit:
hostname: my-rabbit
image: rabbitmq:3-management
container_name: 'rabbitmq'
environment:
RABBITMQ_DEFAULT_USER=admin
RABBITMQ_DEFAULT_PASS=admin
ports:
- 5672:5672
- 15672:15672
- We took the same issue with Docker-compose.yml as follows
- with
image: rabbitmq:3-management-alpine
- with
version: '3.9'
services:
rabbit:
hostname: my-rabbit
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
environment:
RABBITMQ_DEFAULT_USER=admin
RABBITMQ_DEFAULT_PASS=admin
ports:
- 5672:5672
- 15672:15672
- We took the same issue with Docker-compose.yml as follows
- with
image: bitnami/rabbitmq:latest
- bitnami
- with
version: '3.10'
services:
rabbitmq:
hostname: my-rabbit
image: bitnami/rabbitmq:latest
container_name: 'rabbitmq'
environment:
RABBITMQ_USERNAME: admin
RABBITMQ_PASSWORD: admin
ports:
- 5672:5672
- 15672:15672
- the only way to open containers data page via
volumes
-
docker-compose -f "docker-compose.yml" up -d --build
creates the volume- click
Volumes
- click
In use
- click
-
- Create working folder
- Copy definitions.json file in the working folder
- Copy Dockerfile file in the working folder
- Run the command in the windows terminal
docker build . -f Dockerfile -t rabbitmq-phn-bk