我有以下问题:
我有一个用 Python 编写的小型网络应用程序。我在 Docker 容器中运行它。在本地,网络应用程序运行良好。当我将容器部署到 Azure 应用服务时,出现以下错误:
2021-09-07T15:11:32.980846527Z/bin/sh: 1: [gunicorn,: 未找到
这是我的 Dockerfile
FROM python:3.8-slim-buster
EXPOSE 5000
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
WORKDIR /app
COPY . /app
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "dash_app\dashboard:server"]
这是requirements.txt
flask
gunicorn
dash
pandas
我是 docker 和 python 的新手。根据我的理解,pip install 应该在容器本身中安装requirements.txt 中所有内容的最新版本。我不明白为什么找不到gunicorn。
任何帮助将不胜感激。
最佳答案
来自docs :
If you want to run your
<command>
without a shell then you must express the command as a JSON array and give the full path to the executable. This array form is the preferred format ofCMD
. Any additional parameters must be individually expressed as strings in the array.
也就是说,您应该提供 gunicorn
的完整路径可执行文件,或使用shell格式:
CMD gunicorn --bind 0.0.0.0:5000 dash_app\dashboard:server
关于python - Azure/bin/sh : 1: [gunicorn, 中的 Docker 容器:未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69098339/