[英]Docker-compose: cannot connect api container to Minio container
I'm trying to connect my api server to a minio container, i'm using dockercompose like this:我正在尝试将我的 api 服务器连接到 minio 容器,我正在使用 dockercompose,如下所示:
minio:
image: "minio/minio"
# volumes:
# - ./docker-data/minio/data:/data
command: minio server /data
networks:
- backend
environment:
MINIO_ACCESS_KEY: 7PDZZCOFGYUASDCBWW9L
MINIO_SECRET_KEY: cSqaXmYpTk91asduFJ7ZKsZ+8e2pSLOXfc6ycogq
ports:
- "9000:9000"
api:
image: "applications-api"
networks:
- backend
environment:
NODE_ENV: test
ports:
- 3000:3000
# command: npm run dockertest
networks:
backend:
But I keep getting this error, the credentials are the same i cannot understand what i'm doing wrong, I appreciate any kind of help.但我不断收到此错误,凭据相同,我无法理解我做错了什么,我感谢任何帮助。
Error: connect ECONNREFUSED 172.22.0.2:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'NetworkingError',
syscall: 'connect',
address: '172.22.0.2',
port: 443,
region: 'eu-central-1',
hostname: 'minio',
retryable: true,
time: 2020-08-28T13:24:39.702Z```
I suspect the problem is your API tries to connect its own container's localhost.我怀疑问题是你的 API 试图连接它自己的容器的本地主机。
If so, in your API code:如果是这样,在您的 API 代码中:
Try using host.docker.internal
instead of localhost
as minio client endpoint.尝试使用host.docker.internal
而不是localhost
作为 minio 客户端端点。
This will connect your API to the host's localhost.这会将您的 API 连接到主机的 localhost。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.