我需要创建一个 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,[]]}}})
我需要如何更改我的配置?
尝试使用具有管理功能的标签。例如rabbitmq:management-alpine。