I have a Flask Python app that is run via Gunicorn from a Docker Linux container. Running the Docker container on Ubuntu works fine locally, but when the container is pushed to the Azure Container Registry and then deployed as an Azure App, it fails with the following error messages:
- Container my-app_900f4c for site my-app did not start within expected time limit.
- Container my-app_900f4c didn't respond to HTTP pings on port: 80, failing site start.
2020-02-17 INFO - Pull Image successful, Time taken: 0 Minutes and 15 Seconds 2020-02-17 INFO - Starting container for site 2020-02-17 INFO - docker run -d -p 9031:80 --name my-app_900f4c -e PORT=80 -e WEBSITES_PORT=80 -e WEBSITE_SITE_NAME=my-app -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=my-app.azurewebsites.net -e WEBSITE_INSTANCE_ID=eaaf...51e441df96704916ba7b506b6150b26cdc7 -e HTTP_LOGGING_ENABLED=1 myazureappregistry.azurecr.io/my_app:v1 2020-02-17 INFO - Initiating warmup request to container my-app_900f4c for site my-app 2020-02-17 ERROR - Container my-app_900f4c for site my-app did not start within expected time limit. Elapsed time = 255.9515056 sec 2020-02-17 ERROR - Container my-app_900f4c didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging. 2020-02-17 INFO - Stopping site my-app because it failed during startup.
Default Docker Log
2020-02-17  [INFO] Starting gunicorn 20.0.4 2020-02-17  [INFO] Listening at: http://0.0.0.0:80 (1) 2020-02-17  [INFO] Using worker: gthread 2020-02-17  [INFO] Booting worker with pid: 7 2020-02-17  [INFO] Booting worker with pid: 8 2020-02-17  [INFO] Booting worker with pid: 9 2020-02-17  [INFO] Booting worker with pid: 10
In the Azure Portal under Settings > Configuration I have the following Application settings:
- PORT 80
- WEBSITES_PORT 80
FROM python:3.8-slim-buster LABEL Name=my_app Version=0.0.1 EXPOSE 80 WORKDIR /app RUN python3 -m pip install --upgrade pip RUN python3 -m pip install -r requirements.txt ADD . /app CMD ["gunicorn", "-c", "gunicorn.conf.py", "main:app"]
I don't understand what is causing HTTP pings on port
80 to fail, when the logs show that Gunicorn is listening on
Similar questions that have not resolved the issue: