Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container didn't respond to HTTP pings on port: 80, failing site start. #46401

Closed
Bryankarlsson opened this issue Jan 18, 2020 · 21 comments
Closed

Comments

@Bryankarlsson
Copy link

Bryankarlsson commented Jan 18, 2020

I have an docker image containing a .NET Core 3.0 API application that I have pushed to docker hub.

Dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["pswebapi.csproj", ""]
RUN dotnet restore "./pswebapi.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "pswebapi.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "pswebapi.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "pswebapi.dll"]

Inside of Azure, i'm creating a Web app for containers. However, the container seems to fail to start according to the logs:

2020-01-18 18:02:43.659 INFO  - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2020-01-18 18:02:44.181 INFO  - Initiating warmup request to container webapibrajzore_0_66ddf497 for site webapibrajzore
2020-01-18 18:02:44.310 ERROR - Container webapibrajzore_0_66ddf497 for site webapibrajzore has exited, failing site start
2020-01-18 18:02:44.312 ERROR - Container webapibrajzore_0_66ddf497 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2020-01-18 18:02:44.326 INFO  - Stoping site webapibrajzore because it failed during startup.

I have tried to set both PORT and WEBSITES_PORT to 80 in the configuration, but it don't work.

Edited: Added doc details


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@femsulu
Copy link
Member

femsulu commented Jan 18, 2020

Thanks for your comment. We are actively investigating and will get back to you shortly. Thanks for your patience.

@Bryankarlsson
Copy link
Author

When I try to deploy a windows container, I get this error message:
Unable to start container. Error message: Open Compute System failed.

So none of the Linux and windows containers works for me.

@Karishma-Tiwari-MSFT
Copy link
Member

@Bryankarlsson
Since the doc issues are meant to provide feedback on a specific Azure doc, please provide us with the link to the documentation you are referring to so we can better assist.

@Bryankarlsson
Copy link
Author

@Karishma-Tiwari-MSFT Well, I'm following the instructions of how to deploy a docker container to Azure: https://docs.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-docker-webapp?view=azure-devops&tabs=java

@Bryankarlsson
Copy link
Author

Bryankarlsson commented Jan 20, 2020

@VikasPullagura-MSFT @Karishma-Tiwari-MSFT @femsulu the exact same issue that I have can be found here as well in the follwing started issue:

#34451

I have alsoe posted a thread there.

@AjayKumar-MSFT
Copy link
Contributor

@Bryankarlsson, The automatic port detection detects the port (port 80 is the default), we will attempt to detect which port to bind to your container, but you can also use the WEBSITES_PORT app setting and configure it with a value for the port you want to bind to your container. However, the web server in your custom image may use a port other than 80. You tell Azure about the port that your custom container uses by using the WEBSITES_PORT app setting. In this case, yes you will have to change the App Setting configuration from the Portal.

For a different port - Use the EXPOSE instruction in your Dockerfile to expose the appropriate port (E.g 3000) and use the WEBSITES_PORT app setting on Azure with a value of "3000" to expose that port.
Could you please scale-up your App Service Plan and then re-try while I check further on this with your website name.

@Bryankarlsson
Copy link
Author

@AjayKumar-MSFT I'm not sure what it is that you want me to do? I have expsed port 80 in my docker file. Should that not work?

Tell me exactly what you want me to test.

@AjayKumar-MSFT
Copy link
Contributor

AjayKumar-MSFT commented Jan 21, 2020

@Bryankarlsson, Sorry for any confusion! In your comment on the other referenced GitHub issue "Must I set some settings in Configuration -> Application settings in Azure?" ; so in this regard, I had mentioned about using a different Port with the app setting : You can use a different port and then set the application setting with that port using WEBSITES_PORT app setting and see if that makes any difference. As per your case, by default the port 80 should work as only port 80 and 8080 are exposed ports. To isolate, we could try the following steps:

For Windows Container, could you please check if the base image is 2016 and if so kindly leverage the Windows Server 2019 base image (for example: microsoft/aspnet:4.7.2-windowsservercore-ltsc2019) and check if that helps.
An added benefit of this change will be faster load times and higher cost effectiveness due to significantly smaller image size. Please check this announcement for more info on this: https://azure.microsoft.com/en-us/updates/windows-server-2019-support-added-to-public-preview-of-windows-container-support/ .

Could you please confirm if this is your WebApp name 'webapibrajzore'? I'm unable to locate this.
Or could you share the WebApp name directly here or indirectly and also the base image you're leveraging.

@AjayKumar-MSFT
Copy link
Contributor

Since we have not heard back from you we will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply here or on the other thread and we will gladly continue the discussion.

@SyntaxWarrior
Copy link

SyntaxWarrior commented Apr 21, 2020

I just ran in to this issue as well. Pretty much the same premise as OP.
I can build and run my asp net core in Docker Desktop. No issues.
But I get the exackt same error when I try to run it in Azure Web App with a Linux service plan (have not tried windows as it is 2x the price).

I can copy and paste the docker run command that Azure uses (just replacing the image for my local build name) and it works just fine.
docker run -d -p 4880:80 --name web-testmctest-0_e32966d1 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=web-testmctest -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=web-testmctest.azurewebsites.net -e WEBSITE_INSTANCE_ID=5c997bc5776941ff3fb1eb90537ac2f83e1afffea565b14577d6ea1fb7356b3d -e HTTP_LOGGING_ENABLED=1 web-testmctest.azurecr.io/web-testmctest:bt -e WEBSITES_PORT=80 -e environment='Production' -e ASPNETCORE_ENVIRONMENT='Production'

The error:

Container web-testmctest_0_e32966d1 for site web-testmctest has exited, failing site start
Container web-testmctest_0_e32966d1 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.

(I've obfuscated some of the service names and urls as not to expose my real values)

@SyntaxWarrior
Copy link

SyntaxWarrior commented Apr 22, 2020

I've been banging my head against this for days. But I finally figured it out.

Removing the ' from the environment names variables solves the issue, this works:
-e environment=Production -e ASPNETCORE_ENVIRONMENT=Production

Both with and without the ' works in my docker desktop, but Azure fails horribly with no good error message if you have the '

I have specified these extra startup values in Web App > Container Settings > Startup File (form field), same value can be edited from Web App > Configuration > Startup Command (its the same field with a different name).

@AjayKumar-MSFT
Copy link
Contributor

I've been banging my head against this for days. But I finally figured it out.

Removing the ' from the environment names variables solves the issue, this works:
-e environment=Production -e ASPNETCORE_ENVIRONMENT=Production

Both with and without the ' works in my docker desktop, but Azure fails horribly with no good error message if you have the '

I have specified these extra startup values in Web App > Container Settings > Startup File (form field), same value can be edited from Web App > Configuration > Startup Command (its the same field with a different name).

Apologies for all the frustration with this issue and inconvenience. I will share the feedback on this internally with our product team.
Kindly let us know if you need any further assistance. Thanks for sharing the solution that worked for you with the community.

@AX-DevOpsAdmin
Copy link

I've been banging my head against this for days. But I finally figured it out.

Removing the ' from the environment names variables solves the issue, this works:

-e environment=Production -e ASPNETCORE_ENVIRONMENT=Production

Both with and without the ' works in my docker desktop, but Azure fails horribly with no good error message if you have the '

I have specified these extra startup values in Web App > Container Settings > Startup File (form field), same value can be edited from Web App > Configuration > Startup Command (its the same field with a different name).

Apologies for all the frustration with this issue and inconvenience. I will share the feedback on this internally with our product team.

Kindly let us know if you need any further assistance. Thanks for sharing the solution that worked for you with the community.

I'm very sorry, could you shed any more light on this? What is it that must be changed?

@SyntaxWarrior
Copy link

I'm very sorry, could you shed any more light on this? What is it that must be changed?

This works locally with docker desktop: -e environment='Production' -e ASPNETCORE_ENVIRONMENT='Production'
But not in Azure.

This works in Azure
-e environment=Production -e ASPNETCORE_ENVIRONMENT=Production

note the missing '

@vivek781113
Copy link

vivek781113 commented Sep 2, 2020

Facing the same issue as mentioned by @Bryankarlsson. Tried out all the suggestion but no luck as of now. Please find the container logs of the app service.

2020-09-02T17:48:32.007Z INFO - Pull Image successful, Time taken: 0 Minutes and 35 Seconds
2020-09-02T17:48:32.068Z INFO - Starting container for site
2020-09-02T17:48:32.069Z INFO - docker run -d -p 8166:80 --name thintankcoreapi_0_5aec585a -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=thintankcoreapi -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=thintankcoreapi.azurewebsites.net -e WEBSITE_INSTANCE_ID=2a1ab72b2d9ad013ac740eb676404cb06c512c8203547cc3d3c76b3dfea53aee -e HTTP_LOGGING_ENABLED=1 vivek781113/corebase31

2020-09-02T17:48:35.526Z INFO - Initiating warmup request to container thintankcoreapi_0_5aec585a for site thintankcoreapi
2020-09-02T17:48:36.196Z ERROR - Container thintankcoreapi_0_5aec585a for site thintankcoreapi has exited, failing site start
2020-09-02T17:48:36.198Z ERROR - Container thintankcoreapi_0_5aec585a didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2020-09-02T17:48:36.210Z INFO - Stopping site thintankcoreapi because it failed during startup.

@irving-caamal
Copy link

irving-caamal commented May 31, 2021

Hi guys, I've been facing this issue for a couple of days, and finally, I got a solution, I've created a detailed repository with a github workflow that actually works to deploy using azure/webapps-deploy@v2 action. The repo specifies some of the problems that I resolved for my basic node.js application hope it can help someone, 'cause this was a little bit confusing

@AjayKumar-MSFT
Copy link
Contributor

irvv17, Thanks for sharing the solution that worked for you with the community. Apologies for all the confusion. We'll work on adding additional clarity/with author's review.

@tom-juntunen
Copy link

I am still facing this issue:

This is a multi-container image. I am deploying an API written in Python to Linux using Docker Compose, Azure Container Registry and Azure App Service. Right now I cannot get my container to respond to HTTP pings once it is pushed to the Azure Container Registry. I do have Managed Identity turned on ,per this tutorial, to make sure the web app has access to the container registry: https://docs.microsoft.com/en-us/azure/app-service/tutorial-custom-container?pivots=container-linux

Here are my container logs from the failure:

2021-06-27T10:17:41.945Z INFO - docker run -d -p 9397:8080 --name fastapi_0_1501791b -e PORT=8080 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITES_PORT=8080 -e WEBSITE_AUTH_ENABLED=False (remainder omitted)

2021-06-27T10:17:46.225Z INFO - Initiating warmup request to container fastapi_0_1501791b_msiProxy for site fastapi_0_1501791b 2021-06-27T10:17:46.444Z INFO - Container fastapi_0_1501791b_msiProxy for site fastapi initialized successfully and is ready to serve requests.
2021-06-27T10:17:46.446Z INFO - Initiating warmup request to container fastapi_0_1501791b for site fastapi
2021-06-27T10:17:51.758Z ERROR - Container fastapi_0_1501791b for site fastapi has exited, failing site start
2021-06-27T10:17:51.766Z ERROR - Container fastapi_0_1501791b didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2021-06-27T10:17:51.799Z INFO - Stopping site fastapi because it failed during startup.

What am I missing? How do I get the deployed container to respond to HTTP pings?

Here is my Dockerfile ...

FROM python:3.8.8-slim-buster
RUN mkdir -p /home/app

create the app user

RUN addgroup --system app && adduser --system --group app

create the appropriate directories

ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

set environment variables

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV ENVIRONMENT prod
ENV TESTING 0
ENV PORT 8080

install system dependencies

RUN apt-get update
&& apt-get -y install netcat gcc
&& apt-get clean

install python dependencies

RUN python3 -m pip install --upgrade pip
COPY ./requirements.txt .
RUN apt-get -y install postgresql &&
apt-get -y install python-psycopg2 &&
apt-get -y install libpq-dev
RUN python3 -m pip install -r requirements.txt
RUN pip install "uvicorn[standard]==0.13.4"

add files

COPY . .

expose port

EXPOSE 8080

chown all the files to the app user

RUN chown -R app:app $APP_HOME

change to the app user

USER app

run gunicorn and start ssh service

CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]

And my docker-compose.yml ...

version: '3.8'

services:
api:
extends:
file: docker-compose.base.yml
service: api
build:
dockerfile: Dockerfile.prod
image: myazureregistry.azurecr.io/fastapi:latest
ports:
- 8080:8080
environment:
- ENVIRONMENT=prod
- TESTING=0
- DATABASE_URL=${KG_Database}
- DATABASE_TEST_URL=${KG_DatabaseTest}
- PORT=8080

I know this is a lot of detail to send but I have tried all the options I've seen online in forums like this to solve the issue and nothing has worked out for me, so I am wondering if there is something more to my configuration that is awry.

Any ideas? Thank you in advance.

@robisonkarls
Copy link

robisonkarls commented Jan 15, 2023

I m facing the same issue as well.
Here is some of my log.

2023-01-15T03:57:32.020Z INFO - Pull Image successful, Time taken: 0 Minutes and 2 Seconds
2023-01-15T03:57:32.117Z INFO - Starting container for site
2023-01-15T03:57:32.118Z INFO - docker run -d --expose=80 --name w2b-dev-api_0_ed8f04dc -e WEBSITES_PORT=80 -e WEBSITE_SITE_NAME=w2b-dev-api -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=w2b-dev-api.azurewebsites.net -e WEBSITE_INSTANCE_ID=48274e889b02f7890c1050bd386321425fa2cc936574965a145b0eff265739fb -e HTTP_LOGGING_ENABLED=1 -e NODE_OPTIONS=--require /agents/node/build/src/Loader.js -e JAVA_TOOL_OPTIONS=-javaagent:/agents/java/applicationinsights-agent-codeless.jar -e StartupBootstrapper=Microsoft.ApplicationInsights.StartupBootstrapper -e DOTNET_SHARED_STORE=/agents/core/store/lin -e DOTNET_ADDITIONAL_DEPS=/agents/core/additionalDeps -e WEBSITE_USE_DIAGNOSTIC_SERVER=False w2bcrdev.azurecr.io/nofun-inc/where2bite:40708498ac5911832b5db62e94c9ca659579db17

2023-01-15T03:57:33.802Z INFO - Initiating warmup request to container w2b-dev-api_0_ed8f04dc_msiProxy for site w2b-dev-api
2023-01-15T03:57:33.848Z INFO - Container w2b-dev-api_0_ed8f04dc_msiProxy for site w2b-dev-api initialized successfully and is ready to serve requests.
2023-01-15T03:57:33.855Z INFO - Initiating warmup request to container w2b-dev-api_0_ed8f04dc for site w2b-dev-api
2023-01-15T03:57:35.953Z ERROR - Container w2b-dev-api_0_ed8f04dc for site w2b-dev-api has exited, failing site start
2023-01-15T03:57:35.978Z ERROR - Container w2b-dev-api_0_ed8f04dc didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2023-01-15T03:57:36.034Z INFO - Stopping site w2b-dev-api because it failed during startup.

I followed some suggestion like add the WEBSITES_PORT configuration and I added 80 as the value for it, but it didnt work anyway.
I have a dotnet app that is exposing port 80.. but I cant get my app to work with app service on azure.

@HarrySpyrou
Copy link

HarrySpyrou commented May 5, 2023

I don't know how relevant or irrelevant this is to everyone else's problems but I found out why this is happening to me on .NET 6/.NET 7 and in my case it's a bug in Azure. Apologies if it's not relevant to some of this cases but I'm posting here because I believe the problem is framework agnostic.

So, in short, it's the HTTP 2.0 Proxy under Configuration > General Settings in the Azure App Service in the Azure Portal. What is happening is that I'm spinning up my App Services through Terraform and when I don't specifically specify what it needs to do with that specific setting (it's On/Off setting), it does not (I believe) by default set it to off. Instead the radio buttons are NOT selected AT ALL.

So it's not either On or Off, it's null maybe? I can't tell you more, cause I don't work for Azure but when I go and set it specifically to 'Off' manually from the portal, the 8080 port gets released, networking obviously stops being borked and my app just starts working. Screenshot attached of the issue
MicrosoftTeams-image

@Uncle-Yuanl
Copy link

Uncle-Yuanl commented Jul 24, 2023

Hi all, I'm using python runtime to deploy a http service via vscode and encountering this error. Finally I fix this error in my project thanks for all the existed information about this issue. The way I fix this error is to "Fix Python packages".
Here's the entire debug process:
First the error appeared in Azure portal as a tab "Runtime is unreachable".
image
Then I check the Microsoft Troubleshooting Doc and make sure that storage account is configed correctly.
After that, I check whether the runtime container start successfully or not. We can open the log file by typing the URL directly or Deployment tools in portal.

  1. download the docker logs.zip

image
The information in the log file downloaded as zip is limited and we can only see "Container didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.". This error may incorrectly direct our attention to port problems.
I add the application setting WEBSITES_PORT and PORT = 8080, but this error still eixst.

  1. log stream
    image


    This site generates logs in real time as we deploy and make request. Finally, I found the real cause of the problem:
    2.1) asyncio in requirements.txt
    image
    Remove asyncio from requirements.txt
    2.2) import pandas before numpy
    image
    import numpy as np
    import pandas as pd
    Only in this order container works well. And strangely enough, it doesn't give an error when tested locally.
    After fix this personal bug, everything's working well ! ! ! Hope my experience helps :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests