【发布时间】:2020-11-08 18:33:39
【问题描述】:
我已经搜索了几个小时,但找不到根本问题原因。这是我的 docker-compose.yml 文件,您可以在下面看到:
version: "3"
services:
postgres:
image: "postgres:latest"
environment:
- POSTGRES_PASSWORD=postgres_password
redis:
image: "redis:latest"
nginx:
restart: always
build:
dockerfile: Dockerfile
context: ./nginx
ports:
- '3666:80'
depends_on:
- api
- client
api:
build:
dockerfile: Dockerfile.dev
context: ./server
volumes:
- /app/node_modules
- ./server:/app
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
- PGUSER=postgres
- PGHOST=postgres
- PGDATABASE=postgres
- PGPASSWORD=postgres_password
- PGPORT=5432
client:
stdin_open: true
build:
dockerfile: Dockerfile.dev
context: ./client
volumes:
- /app/node_modules
- ./client:/app
worker:
build:
dockerfile: Dockerfile.dev
context: ./worker
volumes:
- /app/node_modules
- ./worker:/app
这是我的 nginx/default.conf
upstream client {
server client:3000;
}
upstream api {
server api:5000;
}
server {
listen 80;
location / {
proxy_pass http://client;
}
location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://api
}
}
当我尝试时:
#docker-compose up --build
过程中出现此错误:
nginx_1 | nginx:在 /etc/nginx/conf.d/default.conf:6 的上游“api:5000”中找不到 [emerg] 主机
【问题讨论】:
-
is
api服务器可通过端口5000访问? -
@Adiii 是的,我在代码中控制:
app.listen(5000, (err) => { console.log('Listening');
标签: docker nginx docker-compose dockerfile