我有一個 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
提交
取消