Docker Networking Question - Outbound UDP Messages not using the Port defined by the UDP Port Rule with Bridge Networking

With Docker Desktop for Windows there is no way around the NAT:

It might work with Docker-CE in a WSL2 distribution, if networkingMode=mirrored is configured in .wslconfig in the user profile folder. Note: wsl2 networkingMode=mirrored is not the same as Docker Desktop’s host networking.

Update:
I should have mentioned two things:

  • with wsl2 mirrored mode the wsl distribution uses the same ip as the host
  • the container needs to be started with --network host, so you get rid of the NAT.

This way, the container should behave like it’s running natively on Linux, or your windows host.