[英]emerg 1#1: host not found in upstream “dashboard-fe:3000” in /etc/nginx/nginx.conf:6
I am beginner in docker
and trying to containerize react and flask application.我是
docker
的初学者,并试图将反应和 flask 应用程序容器化。 There are three containers one for react
, another for flask
and last one for nginx
load balancer.共有三个容器,一个用于
react
,另一个用于flask
,最后一个用于nginx
负载均衡器。 I running all the containers using docker-compose
.我使用
docker-compose
运行所有容器。 On running docker-compose up
command, I am getting following error:-在运行
docker-compose up
命令时,我收到以下错误:-
Creating dashboard_dashboard-be_1 ... done
Creating dashboard_dashboard-fe_1 ... done
Creating dashboard_nginx_1 ... done
Attaching to dashboard_dashboard-fe_1, dashboard_dashboard-be_1, dashboard_nginx_1
dashboard-be_1 | [2021-03-10 17:44:38 +0000] [7] [INFO] Starting gunicorn 20.0.4
dashboard-be_1 | [2021-03-10 17:44:38 +0000] [7] [INFO] Listening at: http://0.0.0.0:5000 (7)
dashboard-be_1 | [2021-03-10 17:44:38 +0000] [7] [INFO] Using worker: threads
dashboard_dashboard-fe_1 exited with code 0
dashboard-be_1 | [2021-03-10 17:44:38 +0000] [10] [INFO] Booting worker with pid: 10
dashboard-be_1 | [2021-03-10 17:44:38 +0000] [11] [INFO] Booting worker with pid: 11
nginx_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx_1 | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
nginx_1 | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx_1 | 2021/03/10 17:44:43 [emerg] 1#1: host not found in upstream "dashboard-fe:3000" in /etc/nginx/nginx.conf:6
nginx_1 | nginx: [emerg] host not found in upstream "dashboard-fe:3000" in /etc/nginx/nginx.conf:6
This seems quite a common error and after going through many answers I tried fixing it with depends_on
but it didn't work.这似乎是一个很常见的错误,在经历了许多答案后,我尝试使用
depends_on
修复它,但它没有用。
Following are my scripts:-以下是我的脚本:-
frontend/Dockerfile前端/Dockerfile
FROM node:10-alpine as build-step
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
RUN npm run build
nginx/Dockerfile nginx/Dockerfile
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
docker-compose.yml docker-compose.yml
version: '3'
services:
dashboard-be:
build: ./Dashboard-be
expose:
- 5000
ports:
- 5000:5000
environment:
- FLASK_ENV=${ENV}
- FLASK_APP=app
- PYTHONDONTWRITEBYTECODE=1
- PYTHONUNBUFFERED=1
networks:
- dashboard_be
dashboard-fe:
build: ./Dashboard-fe
expose:
- 3000
ports:
- 3000:3000
networks:
- dashboard_fe
nginx:
build: ./nginx
tty: true
ports:
- 80:80
networks:
- dashboard_fe
- dashboard_be
depends_on:
- dashboard-fe
- dashboard-be
networks:
dashboard_fe:
dashboard_be:
internal: true
There is no CMD
in your Dockerfile
for the frontend, so the container starts and then exits, as you can see in your logs前端的
Dockerfile
中没有CMD
,因此容器启动然后退出,如您在日志中所见
dashboard_dashboard-fe_1 exited with code 0
Once you correct your Frontend dockerfile and it runs, the whole compose should start working更正您的前端 dockerfile 并运行后,整个组合应该开始工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.