繁体   English   中英

Gunicorn自行运行,但不在docker容器中运行

[英]Gunicorn runs by itself but not in docker container

我正在尝试在Docker容器中运行Gunicorn,这是我的Docker文件

FROM python:3.6-alpine

RUN pip install gunicorn

COPY . /app

EXPOSE 8000


ENTRYPOINT ["gunicorn", "-c", "/app/etc/gunicorn.py", "backend:app"]

我尝试过将backend:appapp:app app:backend等互换,但没有任何效果,它总是会出错并输出

Failed to find application object 'app' in 'app'

构建之后,我运行:

docker run -it -p 8000:8000 backend:latest bash

这是我要复制到/app的文件夹结构。

│   main.py
│   requirements.txt
│
├───backend
│   │   __init__.py
│   │
│   ├───cards
│   │      cards_views.py
│   │      __init__.py
│   │
│
└───etc
        gunicorn.py
        nginx.conf

如果我运行:

gunicorn -c /backend-flask/etc/gunicorn.py backend:app

在容器外部,它运行完美。 因此,它一定与我的文件夹结构有关,但我无法弄清楚。

添加:

pip install -r /app/requirements.txt

Dockerimage文件修复了该问题,并使用:

docker run -it --entrypoint=sh [my container]

最终的dockerfile看起来像:

FROM python:3.6-alpine

RUN pip install gunicorn

COPY . /app

RUN pip install -r /app/requirements.txt

EXPOSE 8000


ENTRYPOINT ["gunicorn", "-c", "/app/etc/gunicorn.py", "backend:app"]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM