我有一个 docker-compose 文件,直到今天它都运行良好,当我尝试使用 gunicorn 启动我的网络服务器时,它刚刚开始抛出错误。日志看起来像: flask_apis | [2019-09-05 21:20:04 +0000] [1] [INFO] Starting gunicorn 19.9.0flask_apis | [2019-09-05 21:20:04 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)flask_apis | [2019-09-05 21:20:04 +0000] [1] [INFO] Using worker: syncflask_apis | [2019-09-05 21:20:04 +0000] [8] [INFO] Booting worker with pid: 8flask_apis | [2019-09-05 21:20:04 +0000] [8] [ERROR] Exception in worker processflask_apis | Traceback (most recent call last):flask_apis | File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_workerflask_apis | worker.init_process()flask_apis | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_processflask_apis | self.load_wsgi()flask_apis | File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgiflask_apis | self.wsgi = self.app.wsgi()flask_apis | File "/usr/local/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgiflask_apis | self.callable = self.load()我的 dockerfile 看起来像FROM python:3.7-slimWORKDIR /appRUN pip install --upgrade pipCOPY requirements.txt .RUN pip install -r requirements.txtCOPY . .还有我的那个服务器的 docker-compose 文件:services: api: build: context: . dockerfile: ./Dockerfile image: flask-pywren container_name: flask_apis command: /usr/local/bin/gunicorn -w 2 -b :8000 fintech.flask_entrypoint:app env_file: - ./docker.env expose: - "8000" volumes: - .:/app/有趣的是我可以在 docker 镜像中打开 sh:docker run -it flask-pywren sh并运行/usr/local/bin/gunicorn -w 2 -b :8000 fintech.flask_entrypoint:appgunicorn 启动良好。我唯一能想到的就是那docker-compose不是从WORKDIR? 我还添加working_dir: "/app"了 docker-compose 文件,但这也不起作用。我真的不知道为什么这突然没有按预期工作。
1 回答
慕虎7371278
TA贡献1802条经验 获得超4个赞
如果您在日志中看到它非常清楚ModuleNotFoundError: No module named 'fintech'。
您需要安装fintech.
FROM python:3.7-slim
WORKDIR /app
RUN pip install --upgrade pip
RUN pip install fintech
至于可以改变 docker 行为的 docker-compose 是
volumes:
- .:/app/
它将覆盖/app在构建期间复制的所有内容COPY . .
添加回答
举报
0/150
提交
取消
