Closed semyonc closed 1 year ago
Hey, thanks for reaching out. This isn't a change I'm planning to make. I chose to make the default address binding localhost-only because that helps developers avoid exposing ports on their machine to remote connections unintentionally. That's just the default behavior, however. You can still choose to expose ports by changing the address binding.
If you want to expose ports when running inside docker, the simplest way to do that is set both address and port parameters.
Example:
dotnet serve -a 0.0.0.0 -p 5000
I hope that helps!
Also FYI I updated the README to clarify this, and also made it easier to enable listening to any IP by using -a any
or --address any
.
See https://github.com/natemcmaster/dotnet-serve/commit/6f65405fb71c43026737c5e3b065ce4dda581d0f
Thanks a lot. I agree that my change is not perfect, I have just spent time to understand why my container is not working. Thanks again
The existing implementation does not work in the docker container: you can't use automatic port assignment because the desired port should be declared. But, if you set the port as a parameter the Kestrel ListenLocalhost() will allow only internal connections that prevents use outside the container.