我需要创建一个docker-compose文件,这样在启动容器后,我就有了一个"myqueue"队列,我可以立即开始工作。
使用docker-compose:
version: '3.8'
services:
rabbitmq:
image: "rabbitmq:latest"
ports:
- "5672:5672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: user
RABBITMQ_DEFAULT_PASS: pass
RABBITMQ_DEFAULT_VHOST: /
volumes:
- type: bind
source: rabbitmq-enabled-plugins
target: /etc/rabbitmq/enabled_plugins
- type: bind
source: rabbitmq.config
target: /etc/rabbitmq/rabbitmq.config
- type: bind
source: rabbitmq-defs.json
target: /etc/rabbitmq/rabbitmq-defs.json
rabbitmq-enabled-plugins
[rabbitmq_management].
rabbitmq.config
[
{
rabbit,
[
{default_user, <<"user">>},
{default_pass, <<"pass">>},
{default_vhost, <<"/">>},
{ loopback_users, [] }
]
},
{
rabbitmq_management,
[
{ load_definitions, "/etc/rabbitmq/rabbitmq-defs.json" }
]
}
].
rabbitmq-defs.json
{
"exchanges": [
{
"name": "myqueue",
"vhost": "/",
"type": "fanout",
"durable": true,
"auto_delete": false,
"internal": false,
"arguments": {}
}
],
"queues": [
{
"name": "myqueue",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
}
],
"bindings": [
{
"source": "myqueue",
"vhost": "/",
"destination": "myqueue",
"destination_type": "queue",
"routing_key": "*",
"arguments": {}
}
]
}
当我尝试启动它时,我得到以下消息:
BOOT FAILED
===========
Exception during startup:
exit:{error,{no_such_vhost,<<"/">>}}
rabbit_boot_steps:-run_step/2-lc$^0/1-0-/2, line 45
rabbit_boot_steps:run_step/2, line 48
rabbit_boot_steps:-run_boot_steps/1-lc$^0/1-0-/1, line 19
rabbit_boot_steps:run_boot_steps/1, line 20
rabbit:start/2, line 958
application_master:start_it_old/4, line 293
Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{{error,{no_such_vhost,<<"/">>}},{rabbit,start,[normal,[]]}}})
我需要如何更改我的配置?
1.我尝试从rabbitmq-defs.json中删除vhost,但正如预期的那样,什么也没有发生。
1.我试图用dockerfile解决这个问题,但是curl有问题,这个解决方案看起来不太好
1条答案
按热度按时间mccptt671#
尝试使用管理标签。例如rabbitmq:management-alpine。