Docker container in Azure /bin/sh: 1: [gunicorn,: not found

Viewed 504

I have the following problem:

I have a small web app written in Python. I run it in a docker container. Locally the web app works fine. When I deploy the container to Azure App Service I get the following error:

2021-09-07T15:11:32.980846527Z /bin/sh: 1: [gunicorn,: not found

Here is my 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"]

And here is the requirements.txt

flask
gunicorn
dash
pandas

I am new to docker and python. From my understanding pip install should install the latest version of everything from requirements.txt in the container itself. I don't understand why the gunicorn cannot be found.

Any help will be greatly appreciated.

1 Answers

From the 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.

That is, you should provide the full path to gunicorn executable, or use the shell format:

CMD gunicorn --bind 0.0.0.0:5000 dash_app\dashboard:server
Related