'Deploying Docker Container Registry on Azure App Service Issue

I am unable to rum Docker Container Registry on the Azure App service. I have a flask app and the following is the Dockerfile of it:-

FROM python:3.8-slim-buster
WORKDIR /usr/src/app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# copy project
WORKDIR /usr/src/app
COPY . /usr/src/app/

# expose port 80
EXPOSE 80
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:80", "app:app"]

I have deployed the docker image on the Container Registry. I have also set WEBSITES_PORT to 80 under App Service -> Application Settings. Even after doing that, I get the following error:-

  ERROR - Container XYZ didn't respond to HTTP pings on port: 80, failing site start.

I have tried running it locally and it works fine. But, it just does not seem to work on the Azure App service. Any help is highly appreciated.



Solution 1:[1]

I don't see an issue in the code you posted but to verify, here is a configuration for a Flask app with a Gunicorn server that works on a containerized Azure App Service:

app.py

from flask import Flask
    
app = Flask(__name__)
    
@app.route("/")
def hello_world():
    return "<p>Hello World!</p>"

Dockerfile

FROM python:3.8-slim-buster
ADD app.py app.py
ADD requirements.txt requirements.txt
RUN pip install --upgrade pip
RUN python3 -m pip install -r requirements.txt

EXPOSE 80

CMD ["gunicorn", "--bind=0.0.0.0:80", "app:app"]

requirements.txt

flask
gunicorn

I assume you selected "Docker Container" when you created the Azure App Service?

enter image description here

And then simply chose your image?

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christian Vorhemus