当我运行我的Docker镜像时,出现“gunicorn:command not found”的错误。当我进入镜像并手动运行它时,我得到了相同的错误。
然而,
以下是构建此镜像所需的文件:
Dockerfile
然而,
pip install gunicorn
的输出确认它已经安装了。Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: gunicorn in ./.local/lib/python3.10/site-packages (20.1.0)
Requirement already satisfied: setuptools>=3.0 in /usr/local/lib/python3.10/site-packages (from gunicorn) (58.1.0)
以下是构建此镜像所需的文件:
Dockerfile
FROM python:3.10.5-alpine
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN adduser -D appuser
USER appuser
WORKDIR /home/appuser/
COPY --chown=appuser:appuser requirements.txt .
RUN python -m pip install --user --no-cache-dir --disable-pip-version-check --requirement requirements.txt
COPY --chown=appuser:appuser . .
ENTRYPOINT [ "./entrypoint.sh" ]
requirements.txt
django==4.0.6
psycopg2-binary==2.9.3
gunicorn==20.1.0
entrypoint.sh
#!/bin/sh
python manage.py makemigrations
python manage.py migrate
python manage.py collectstatic --no-input
gunicorn project.wsgi:application --bind=0.0.0.0:8000 --workers=4 --timeout=300 --log-level=debug --log-file=-