'empty response - Docker Container ASP.NET CORE 6

I got stuck on this for quite some time and i don't know why it doesn't work.

I looked into posts similair to mine but i can't fix it, (tried checking the firewall settings, using different ports).

I have a Dockerfile that looks like this:

# syntax=docker/dockerfile:1
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY bin/Release/net6.0/publish/ App/
WORKDIR /App
ENTRYPOINT ["dotnet", "MonitorApplication1.dll"]

The application is a simple REST API with C# .NET Core 6. The database is a MS SQL Server Database.

The image and container seem fine but when i try to view it in the browser (using Chrome as standard, but also tried Edge) i get the ERR_EMPTY_RESPONSE error.

The log of the container (using Docker Desktop) only shows this: {"EventId":14,"LogLevel":"Information","Category":"Microsoft.Hosting.Lifetime","Message":"Now listening on: http://[::]:80","State":{"Message":"Now listening on: http://[::]:80","address":"http://[::]:80","{OriginalFormat}":"Now listening on: {address}"}}

Update

I tried to create a new .NET 6 API with Docker Enabled but when i tried to run the container i still get the Error Empty Response.



Solution 1:[1]

I solved a similar problem by adding the ASPNETCORE_URLS environment variable, like this:

ENV ASPNETCORE_URLS=http://*:5000

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 Javier Molina