Simple Gradio App in Docker Container does not work in Azure Container Registrey für Azure Webapp

I try to create a webapp in Azure, which uses a docker image for a python based Gradio app, which I pushed to my Azure Container Registry before. I can’t access the webapp via the default domain. I get the following error message in the deployment logs in Azure:

2024-08-18T07:11:52.561Z INFO - Initiating warmup request to container hello-app-mgl_0_a90587a3 for site hello-app-mgl 2024-08-18T07:11:52.598Z ERROR - Container hello-app-mgl_0_a90587a3 for site hello-app-mgl has exited, failing site start 2024-08-18T07:11:52.635Z ERROR - Container hello-app-mgl_0_a90587a3 didn’t respond to HTTP pings on port: 7860, failing site start. See container logs for debugging.

def greet(name):return f"Hello {name}!"
        iface = gr.Interface(fn=greet,
inputs="text",outputs="text").launch(server_name="0.0.0.0", server_port=7860)
This is my dockerfile:

FROM python:3.12
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
ENV GRADIO_SERVER_PORT=7860ENV GRADIO_SERVER_NAME=0.0.0.0
EXPOSE 7860
COPY . .
ENTRYPOINT ["python3"]
CMD ["./app.py", "--server.port=0000", "--server.port=7860" ]

I try to create a webapp in Azure, which uses a docker image for a python based Gradio app, which I pushed to my Azure Container Registry before. I can’t access the webapp via the default domain. I get the following error message in the deployment logs in Azure:

2024-08-18T07:11:52.561Z INFO - Initiating warmup request to container hello-app-mgl_0_a90587a3 for site hello-app-mgl 2024-08-18T07:11:52.598Z ERROR - Container hello-app-mgl_0_a90587a3 for site hello-app-mgl has exited, failing site start 2024-08-18T07:11:52.635Z ERROR - Container hello-app-mgl_0_a90587a3 didn’t respond to HTTP pings on port: 7860, failing site start. See container logs for debugging.

This is the code of my simple Gradio app: import gradio as gr

def greet(name):return f"Hello {name}!"
        iface = gr.Interface(fn=greet,
inputs="text",outputs="text").launch(server_name="0.0.0.0", server_port=7860)

This is my dockerfile:

FROM python:3.12
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
ENV GRADIO_SERVER_PORT=7860ENV GRADIO_SERVER_NAME=0.0.0.0
EXPOSE 7860
COPY . .
ENTRYPOINT ["python3"]
CMD ["./app.py", "--server.port=0000", "--server.port=7860" ]

I created a docker image from this dockerfile: docker build -t demo-gradio-app .

I tagged and pushed this docker image to my Azure container registry, which worked well.

I created the webapp with the before pushed docker image in the Azure container registry.

I set the environment variable in the setting of the webapp to: WEBSITES_PORT 7860

I restarted the webapp multiple times.

But, I still get this error in the deployment logs:

2024-08-18T07:11:52.561Z INFO - Initiating warmup request to container hello-app-mgl_0_a90587a3 for site hello-app-mgl

2024-08-18T07:11:52.598Z ERROR - Container hello-app-mgl_0_a90587a3 for site hello-app-mgl has exited, failing site start

2024-08-18T07:11:52.635Z ERROR - Container hello-app-mgl_0_a90587a3 didn’t respond to HTTP pings on port: 7860, failing site start. See container logs for debugging.