Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
docker compose up在本地工作,而不是部署_Docker_Docker Compose - Fatal编程技术网

docker compose up在本地工作,而不是部署

docker compose up在本地工作,而不是部署,docker,docker-compose,Docker,Docker Compose,在我的部署中 ubuntu@ip-172-31-28-117:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 56262dfb645a short_text_understanding_frontend &q

在我的部署中

ubuntu@ip-172-31-28-117:~$ docker ps
CONTAINER ID        IMAGE                               COMMAND                  CREATED             STATUS              PORTS                NAMES
56262dfb645a        short_text_understanding_frontend   "/docker-entrypoint.…"   20 hours ago        Up 7 minutes        0.0.0.0:80->80/tcp   short_text_understanding_frontend_1
4aec8408f651        short_text_understanding_ner        "gunicorn --bind 0.0…"   20 hours ago        Up 7 minutes        5000/tcp             short_text_understanding_ner_1
ubuntu@ip-172-31-28-117:~$ dig +short myip.opendns.com @resolver1.opendns.com
54.87.175.43
ubuntu@ip-172-31-28-117:~$
但如果我在浏览器中键入
54.87.175.43
,则连接超时

这是一段摘自《docker compose up》

ubuntu@ip-172-31-28-117:~/short_text_understanding$ docker-compose up
Starting short_text_understanding_ner_1 ... done
Starting short_text_understanding_frontend_1 ... done
Attaching to short_text_understanding_ner_1, short_text_understanding_frontend_1
frontend_1  | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
frontend_1  | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
frontend_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
frontend_1  | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
frontend_1  | 10-listen-on-ipv6-by-default.sh: error: /etc/nginx/conf.d/default.conf differs from the packages version
frontend_1  | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
frontend_1  | /docker-entrypoint.sh: Configuration complete; ready for start up
ner_1       | 2020-10-08 08:54:01,172 loading file /root/.flair/models/en-upos-ontonotes-fast-v0.4.pt
ner_1       | [2020-10-08 08:54:07 +0000] [1] [INFO] Starting gunicorn 20.0.4
ner_1       | [2020-10-08 08:54:08 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
ner_1       | [2020-10-08 08:54:08 +0000] [1] [INFO] Using worker: gevent
ner_1       | [2020-10-08 08:54:08 +0000] [8] [INFO] Booting worker with pid: 8
我觉得一切都很好。这里有什么问题

我的开发环境是MacOS,部署环境是Ubuntu 18.04 LTS

docker compose.yml

version: '3.8'

services:
   ner:
       build: ./src_python
       command: gunicorn --bind 0.0.0.0:5000 wsgi:app --preload -k gevent --worker-connections 5
       expose:
           - 5000
   frontend:
       build:
           context: .
           dockerfile: Dockerfile
       ports:
           - 80:80
       stdin_open: true
       depends_on:
           - ner
FROM node:14-alpine3.12 AS build_stage
WORKDIR /
COPY package.json package-lock.json ./
RUN npm install
COPY src ./src
COPY public ./public
RUN npm run build

FROM nginx:alpine
COPY --from=build_stage /build/ /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
FROM python:3.7-slim
COPY . /app

WORKDIR /app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# RUN python -c 'import flair; _ = flair.models.SequenceTagger.load("upos-fast"); _ = flair.embeddings.FlairEmbedding("news-forward"); _ = flair.embeddings.FlairEmbedding("news-backward");'

ENV FLASK_ENV production
/Dockerfile

version: '3.8'

services:
   ner:
       build: ./src_python
       command: gunicorn --bind 0.0.0.0:5000 wsgi:app --preload -k gevent --worker-connections 5
       expose:
           - 5000
   frontend:
       build:
           context: .
           dockerfile: Dockerfile
       ports:
           - 80:80
       stdin_open: true
       depends_on:
           - ner
FROM node:14-alpine3.12 AS build_stage
WORKDIR /
COPY package.json package-lock.json ./
RUN npm install
COPY src ./src
COPY public ./public
RUN npm run build

FROM nginx:alpine
COPY --from=build_stage /build/ /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
FROM python:3.7-slim
COPY . /app

WORKDIR /app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# RUN python -c 'import flair; _ = flair.models.SequenceTagger.load("upos-fast"); _ = flair.embeddings.FlairEmbedding("news-forward"); _ = flair.embeddings.FlairEmbedding("news-backward");'

ENV FLASK_ENV production
/python\u src/Dockerfile

version: '3.8'

services:
   ner:
       build: ./src_python
       command: gunicorn --bind 0.0.0.0:5000 wsgi:app --preload -k gevent --worker-connections 5
       expose:
           - 5000
   frontend:
       build:
           context: .
           dockerfile: Dockerfile
       ports:
           - 80:80
       stdin_open: true
       depends_on:
           - ner
FROM node:14-alpine3.12 AS build_stage
WORKDIR /
COPY package.json package-lock.json ./
RUN npm install
COPY src ./src
COPY public ./public
RUN npm run build

FROM nginx:alpine
COPY --from=build_stage /build/ /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
FROM python:3.7-slim
COPY . /app

WORKDIR /app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# RUN python -c 'import flair; _ = flair.models.SequenceTagger.load("upos-fast"); _ = flair.embeddings.FlairEmbedding("news-forward"); _ = flair.embeddings.FlairEmbedding("news-backward");'

ENV FLASK_ENV production

可能吧。你能确定你的docker-compose.yml文件吗?您是否使用dotenv和dotenv-safe根据环境传递变量?我正在编辑您的评论:D。不,我没有使用dotenv。我不是docker专家,但我有几点建议。对于ner更改,请尝试更改暴露到端口。还要考虑添加一个他们都共享的网桥。你是在EC2上运行的,还是在类似的云环境下运行的?您的安全组和其他网络配置是否允许入站请求?@DavidMaze请回答您的评论,以便接受。史蒂夫,谢谢你的建议。在这里添加网桥有什么好处?