✅ .Net 8 WebApi not responding from Docker container
I am running a default .Net 8 webapi project that I created via the dotnet CLI
The project builds and runs locally, I am able to get a response.
Dockerfile
I build the image and run it
Cannot get a response from the api
Any help appreciated!
6 Replies
what do the logs of the container say which port kestrel is listening on?
Highly doubt kestrel is listening to 80
so yeah, check the container logs for the
message
thats the port you need to expose and map up as your in-container port
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Thanks for the response guys.. I've been at work so I couldn't get answers out.
Here's the logs. I'm just getting started with Docker, so I am trying to understand a bit here. I exposed 80, Kestrel is listening on 8080, so traffic is not getting to the container since it's listening on the wrong port?
![No description](https://cdn.answeroverflow.com/1261144042637365370/image.png)
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
the
-p 5154:80
part of the docker run command means that u tunnel/bind the host port 5154 to the container internal's port 80.
Now listening on http://0.0.0.0:5154
means that its listening for any IP on port 5154, which is within the docker container.
so basically, if u swap the ports to -p 80:5154
, requests like http://localhost/weatherforecast
would do the trick here, to make it work.
and that weird port configuration, as TeBeCo already mentioned, should be investigated as well.