docker 内的 RabbitMQ 不会正常结束并且无法重新连接
RabbitMQ inside docker won't end gracefully and cannot reconnect
我正在尝试在 2 个 docker 容器中使用 RabbitMQ 进行 RPC。我将它们设置如下:
chindow:
image: bablot/chindow
ports:
- "9999:9999"
links:
- rabbitmq:amq
rabbitmq:
image: rabbitmq:3
ports:
- "15672:15672"
一开始一切都按预期工作,但随后,当我使用 ctrl+c
关闭系统时,它导致以下错误:
babelotserver_rabbitmq_1 exited with code 143
然后当我继续重启系统时:
chindow_1 | { [Error: connect ECONNREFUSED 172.17.0.3:5672]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '172.17.0.3',
port: 5672 }
编辑:
当我 docker stop
rabbitmq 我得到 code 143
当我 docker stop
node.js 我得到 code 0
为什么这两个不同?这有意义吗?
确保您使用的是 docker-compose format Version 2。
它将创建一个桥接网络:参见“Networking in Compose”
这将允许您的容器停止并重新启动,同时仍然能够 see/contact 彼此。
By default Compose sets up a single network for your app.
Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.
我正在尝试在 2 个 docker 容器中使用 RabbitMQ 进行 RPC。我将它们设置如下:
chindow:
image: bablot/chindow
ports:
- "9999:9999"
links:
- rabbitmq:amq
rabbitmq:
image: rabbitmq:3
ports:
- "15672:15672"
一开始一切都按预期工作,但随后,当我使用 ctrl+c
关闭系统时,它导致以下错误:
babelotserver_rabbitmq_1 exited with code 143
然后当我继续重启系统时:
chindow_1 | { [Error: connect ECONNREFUSED 172.17.0.3:5672]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '172.17.0.3',
port: 5672 }
编辑:
当我 docker stop
rabbitmq 我得到 code 143
当我 docker stop
node.js 我得到 code 0
为什么这两个不同?这有意义吗?
确保您使用的是 docker-compose format Version 2。
它将创建一个桥接网络:参见“Networking in Compose”
这将允许您的容器停止并重新启动,同时仍然能够 see/contact 彼此。
By default Compose sets up a single network for your app.
Each container for a service joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.