How does docker port mapping work on windows?

As far as I understood, it uses iptables on Linux and it allows to forward traffic not only by ip but also by port.

Now, in case of windows we have docker running in WSL2. Image name is docker-desktop. It has assigned ip address and exposes some ports. I can reach this VM through virtual adapter in windows.

On my machine it is

Ethernet adapter vEthernet (WSL): Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::2111:6704:7dea:56d5%49 IPv4 Address. . . . . . . . . . . : 172.30.176.1 Subnet Mask . . . . . . . . . . . : 255.255.240.0 Default Gateway . . . . . . . . . :

Also I can connect to those ports on my localhost. How does docker do it? Does it run a proxy for every port? I guess you can't forward traffic by ip + port in windows, so there should be some other mechanism.

2

1 Answer

This is aHyper-V Virtual Switch. It's not a proxy.

It is a virtual network adapter that looks to Windows identical to any physical adapter. The difference is that its driver is part of Hyper-V, and it handles all packets that are sent to/from the adapter.

Packets destined to outside of the computer will be sent via the real physical adapter of the computer and answers received via the established connection.

8

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like