Letting Windows containers and host communicate without firewall prompt

Viewed 37

On Windows 11 with Docker Desktop, I'm running an application where part of it runs on the host and part of it runs on some Docker containers that the host's application process launches. The containers' application processes actually run the same executable (by -v mounting from the host) but with different options. That uses networking, right? But inside my application, when the host tries to communicate with the client, it gets blocked by the firewall and the user is shown the "Windows Security Alert":

Windows Security Alert

I don't understand why this is necessary since the -v mounting is working without it. Also, the user actually must check PUBLIC networks to get it working, even though my current Ethernet LAN connection is set to private.

One alternative could be running this inside the host application:

netsh advfirewall firewall add rule name="TestRunner" dir=in action=allow protocol=tcp program="{Assembly.GetExecutingAssembly().Location}"

But running that will issue a UAC prompt which is more opaque than the Windows Security Alert (at least it doesn't require the user to change the checkbox though).

I'm using the default Docker container networking and adding -it to the Docker run command.

I'd like to avoid either of the networking prompts. Is that possible?

1 Answers

I think your problem is not related to -v mounting a volume. Mounting a volume gives a container access to a volume on the host via other mechanism, not networking. I think your problem that this app is not allowed to run properly on your machine - not exactly a Docker issue. One option is you can add this rule you just described via GPO - if you have that available. Otherwise, you can config the machine manually with a local policy.

Related