gpt4 book ai didi

docker - RabbitMQ在不同docker容器中的状态

转载 作者:行者123 更新时间:2023-12-02 20:07:38 24 4
gpt4 key购买 nike

我正在使用RabbitMQ启动Docker容器以进行测试。我想启动第二个运行简短命令的容器,并检查Rabbitmq是否正在运行。第二个容器应阻塞我的构建管道,直到确定RabbitMQ已在第一个容器中成功启动为止。

如何指定rabbitmqctl使用哪个主机名来获取RabbitMq的状态? 我通过docker将两个容器链接在一起,所以端口问题应该不是问题。

例:

rabbitmqctl -n rabbitmq status # does not work, prints diagnostic info

Status of node rabbitmq@rabbitmq ... Error: unable to perform an operation on node 'rabbitmq@rabbitmq'. Please see diagnostics information and suggestions below.

Most common reasons for this are:

  • Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
  • CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
  • Target node is not running

In addition to the diagnostics info below:

DIAGNOSTICS

attempted to contact: [rabbitmq@rabbitmq]

rabbitmq@rabbitmq: * connected to epmd (port 4369) on rabbitmq * epmd reports: node 'rabbitmq' not running at all other nodes on rabbitmq: [rabbit] * suggestion: start the node

Current node details: * node name: rabbitmqcli52@e3ea1e73df02 * effective user's home directory: /var/lib/rabbitmq * Erlang cookie hash: AB9AFN3zvcyAWBl6ZVVOJw==

最佳答案

您的第二个容器需要注意第一个容器:

docker run --link rabbitmq ...

主机现在可以从容器内部使用:
$ grep rabbitmq /etc/hosts
172.17.0.2 rabbitmq 01ad3098b423

$ ping rabbitmq
PING rabbitmq (172.17.0.2): 56 data bytes
64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.073 ms

请记住,容器链接是 deprecated而不是 custom networks

关于docker - RabbitMQ在不同docker容器中的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48702615/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com