Closed NoahSurprenant closed 2 months ago
I don't think there is a way to make this work currently. I'll log an internal backlog item for us to investigate.
While our tools doesn't support it, you can globally configure Docker to use 127.0.0.1 by default and then -P will bind to it. https://docs.docker.com/network/packet-filtering-firewalls/#setting-the-default-bind-address-for-containers
Closing as there is a workaround available. If we get more upvotes we can re-open and consider.
I am using .NET 6 and Microsoft.VisualStudio.Azure.Containers.Tools.Targets Version 1.19.6.
When launching from Visual Studio with my Docker profile I expect that I should be able to bind only to one IP address on my host machine rather than all. For example I would like to bind only to 127.0.0.1 so my application is only accessible to my machine. I have attempted setting my Docker profile in launchSettings.json like so:
But this only seems to work if I remove applicationUrl and sslPort from my iisExpress settings. If I do not remove them then it binds to all network interfaces using the ports specified in iisExpress settings. I would not expect my iisExpress settings to have any affect on my docker profile. Also Visual Studio regenerates the properties after restarting, not to mention that me removing them means I cannot run in IIS Express configuration.
Is there another way to specify which IP address to bind to on the host, or at least specify localhost only?