python - Azure/bin/sh : 1: [gunicorn, 中的 Docker 容器:未找到

标签 python azure docker

我有以下问题:

我有一个用 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 of CMD. 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/

相关文章:

python - 使用 re 在另一个字符串中查找一个字符串

python - 将命名空间添加到 DOM 元素 python

python - HTTPResponse 对象没有属性 json

git - C# 从 Azure 应用服务将文件推送到 Bitbucket 存储库?

java - Docker:java:openjdk-8-jdk-alpine 图像缺少 javac 和 tools.jar

java - Docker compose mysql 容器在依赖它的应用程序之后运行

python - 如何让两个不同的函数并行运行并在Python中返回一个数组

c# - autofac 不适用于 azure 网站上的 WebAPI 2

azure - 是否可以将订阅 key 查询字符串参数与 Azure API 管理 SOAP 传递结合使用?

docker - dockerfile中cmd和入口点之间的区别