I'm trying to run a .NET 5 web application in a Docker container locally with Docker Desktop. Nothing fancy, it's just a new ASP.NET Core Web Application created with Visual Studio 2019. Starting the web application from Visual Studio works, it loads the /swagger/index.html page in the browser.
Then I added Container Support in Visual Studio with Docker Compose. When I start that, it fails to load in the browser. The error in the browser is ERR_EMPTY_RESPONSE. The container is still running at this point. The container logs don't show any errors.
This is what the Docker file of the web app looks like:
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["WebApplication2/WebApplication2.csproj", "WebApplication2/"]
RUN dotnet restore "WebApplication2/WebApplication2.csproj"
COPY . .
WORKDIR "/src/WebApplication2"
RUN dotnet build "WebApplication2.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "WebApplication2.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication2.dll"]
And the docker-compose.yml:
version: '3.7'
services:
webapplication2:
image: ${DOCKER_REGISTRY-}webapplication2
build:
context: .
dockerfile: WebApplication2/Dockerfile
environment:
- ASPNETCORE_URLS=http://*:3000
- ASPNETCORE_ENVIRONMENT=Development
ports:
- "3000:80"
Docker container logs show:
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:3000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://[::]:3000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
I inspected the container. The ports config and the entry point:
"Ports": {
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "3000"
}
]
}
"Entrypoint": [
"tail",
"-f",
"/dev/null"
]
How can I debug this further?