aleksww
(Aleksander Wercis)
February 11, 2024, 11:12am
1
I want to run a basic ASP.NET Core application not from Visual Studio but from command prompt but I can’t - I get ERR_EMPTY_RESPONSE in browser: I tried on THREE different computers. I think it can be related to the newest version of .NET Core which I am using.
This is my application:
I executed commands:
docker build -t dockerdemo .
docker run -d -p 8080:80 --name myapp dockerdemo
And http://localhost:8080/ gives me ERR_EMPTY_RESPONSE each time.
Please help. I am new in Docker.
rimelek
(Ákos Takács)
February 11, 2024, 11:25am
2
I’M not a C# developer, but didn’t you run the application on port 8080?
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60146",
Or is it just an external port in that settings?
The error message indicates the application is not listening on that port or listening but don’t answer.
Make sure the port mapping is right. The right side of the mapping is the port that the app is listening on inside the container.
aleksww
(Aleksander Wercis)
February 11, 2024, 11:28am
3
I think the application is listening on port 8080 because I see on a console:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:8080
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app
aleksww
(Aleksander Wercis)
February 11, 2024, 11:33am
4
I had to use:
docker run -d -p 5000:8080 dockerdemo
And now:
http://localhost:5000/WeatherForecast
WORKS !!!
rimelek
(Ákos Takács)
February 11, 2024, 10:28pm
5
I see I my previous answer was confusing.
I meant that the app was not listening on the port (port 80) to which you forwarded the host port (port 8080)
Good that you could still get to the solution I tried to suggest because I wouldn’t have understood myself either.