我有一个依赖于rabbitmq 的python docker 容器。我尝试使用 docker-compose 文件链接这两个容器:
version: "3.8"
services:
rabbitmq:
image: rabbitmq:3-management
hostname: my-rabbit
volumes:
- ./rabbitmq/etc/configurations.json:/etc/rabbitmq/configurations.json
- ./rabbitmq/etc/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
ports:
- 5672:5672
- 15672:15672
- 25672:25672
networks:
- ihddocker
notification:
image: ihdnotification
restart: on-failure
links:
- rabbitmq
depends_on:
- rabbitmq
networks:
- ihddocker
networks:
ihddocker:
external:
name: ihddocker
我在 python 应用程序容器中收到以下错误 -
File "broker.py", line 22, in start_consumer
connection = pika.BlockingConnection(message_broker_params)
File "/usr/local/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 359, in __init__
self._impl = self._create_connection(parameters, _impl_class)
File "/usr/local/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError
这是 AMQP_SERVER_URL=amqp://guest:guest@localhost:5672,
我尝试先运行 rabbitmq 容器,然后运行 python 容器来检查它是否有效,但它会引发相同的错误。