简体   繁体   English

emerg 1#1:在 /etc/nginx/nginx.conf:6 的上游“dashboard-fe:3000”中找不到主机

[英]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.

相关问题 nginx:在 /etc/nginx/conf.d/nginx.conf:12 的上游“php”中找不到 [emerg] 主机 - nginx: [emerg] host not found in upstream "php" in /etc/nginx/conf.d/nginx.conf:12 nginx:在/etc/nginx/nginx.conf:44的上游“ tellform”中找不到[emerg]主机 - nginx: [emerg] host not found in upstream “tellform” in /etc/nginx/nginx.conf:44 docker vs docker-compose nginx:[emerg] host在/etc/nginx/nginx.conf:21的上游“httpstat.us”中找不到 - docker vs docker-compose nginx: [emerg] host not found in upstream “httpstat.us” in /etc/nginx/nginx.conf:21 Docker Nginx 停止:[emerg] 1#1:在上游找不到主机 - Docker Nginx stopped: [emerg] 1#1: host not found in upstream nginx:[emerg] 在 /etc/nginx/conf.d/default.conf 的上游“api:5000”中找不到主机 - nginx: [emerg] host not found in upstream "api:5000" in /etc/nginx/conf.d/default.conf 运行独立 docker 容器时,在 /etc/nginx/conf.d/nginx.conf 上游中找不到主机 - host not found in upstream in /etc/nginx/conf.d/nginx.conf when running standalone docker containers nginx:在 /etc/nginx/sites-available/todo.conf:29 的上游“todo”中找不到 [emerg] 主机 - nginx: [emerg] host not found in upstream “todo” in /etc/nginx/sites-available/todo.conf:29 在 /etc/nginx/nginx.conf 的上游“php”中找不到 Docker Azure 主机 - Docker Azure host not found in upstream "php" in /etc/nginx/nginx.conf AWS ECR,基于 ECS 的部署:nginx:[emerg] 主机未在上游“app:9000”中找到,位于 /etc/nginx/conf.d/default.conf:2 - AWS ECR, ECS based deployment: nginx: [emerg] host not found in upstream "app:9000" in /etc/nginx/conf.d/default.conf:2 Docker 撰写错误:nginx:在 /etc/nginx/conf.d/default.conf:21 的上游“应用程序”中找不到 [emerg] 主机 - Docker compose error: nginx: [emerg] host not found in upstream “app” in /etc/nginx/conf.d/default.conf:21
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM