我无法将node.js应用程序与Rabbit-mq服务器连接。 Postgres已正确连接。我不知道为什么我的连接被拒绝。
version: "3"
networks:
app-tier:
driver: bridge
services:
db:
image: postgres
environment:
- POSTGRES_USER=dockerDBuser
- POSTGRES_PASSWORD=dockerDBpass
- POSTGRES_DB=performance
ports:
- "5433:5432"
volumes:
- ./pgdata:/var/lib/postgresql/data
networks:
- app-tier
rabbitmq:
image: rabbitmq:3.6.14-management
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:5672"]
interval: 30s
timeout: 10s
retries: 5
ports:
- "0.0.0.0:5672:5672"
- "0.0.0.0:15672:15672"
networks:
- app-tier
app:
build: .
depends_on:
- rabbitmq
- db
links:
- rabbitmq
- db
command: npm run startOrc
environment:
DATABASE_URL: postgres://dockerDBuser:dockerDBpass@db:5432/asdf
restart: on-failure
networks:
- app-tier
似乎正在尝试连接到主机Rabbitmq而不是容器Rabbitmq
答案 0 :(得分:2)
尝试将环境变量> export HOME=/home/mjain8
> cat home.txt
$HOME:1:2
$HOME:1:2 3
> perl -F: -lane ' {$F[0]=$ENV{HOME} ;print join(":",@F) } ' home.txt
/home/mjain8:1:2
/home/mjain8:1:2 3
> perl -F: -lane ' {$F[0]=$ENV{HOME} if $F[0]=~/\$HOME/;print join(":",@F) } ' home.txt # if you need to explicity check if it is HOME
/home/mjain8:1:2
/home/mjain8:1:2 3
>
更改为CLOUDAMQP_URL
您可以通过服务名称amqp://rabbitmq:5672
来致电服务。