Proxies loopback (localhost) traffic for Docker Windows Containers to work around Windows NAT limitations.
This NAT issue has been resolved on newer Windows Insider builds (stable and fast ring) and with the latest versions of Docker. There are still people out there on RTM versions of Windows where this utility could be useful, but I didn't like writing or having to run this utility. So if you don't like running it and it's feasible for you, upgrading to the Windows Insider Slow Ring release will remove the need.
To run DockerProxy, you'll need to either:
- Download and extract the Latest Release
- Launch DockerProxy.exe
- Download and install the dotnet core SDK
- Clone this repository or download source from latest release:
git clone https://github.com/Kymeric/DockerProxy.git
- Open a powershell window in the top-level directory
- Launch
./run.ps1
to build and launch DockerProxy
Windows Containers running on Docker for Windows (when using the default 'nat' networking) don't accept connections from/to localhost. There are several references to this issue:
Scott Hanselman calling it a bug
This GitHub issue (that was closed)
Scott classified it as a bug but I haven't been able to find any further information explaining if a fix is being worked on, or when we could expect it to land. If anyone has more details on the plans for resolving this or if it's going to be resolved, I'd like to hear that and I can add that here. But in the meantime this issue has been enough of a challenge for me over the last 6 months that I decided to put this utility together as a workaround.
This is a simple dotnet core console app that acts as a TCP proxy. In local testing it seems to work pretty reliably for any TCP/HTTP/WebSocket traffic. It uses the docker CLI to monitor running docker instances and which ports they're exposing. It then listens on localhost:{port} for incoming connections, proxying them on to the correct container's NAT IP address.
It will detect new containers launching or existing containers exiting and listen/stop accordingly. So far I've only tested this with simple/basic docker nat networking. It may work for more advanced docker networking configurations but I haven't tested them yet. Please file issues for any problems you run into, or submit a pull request if you have the time to help out.
As mentioned, I don't know the plans for resolving the NAT limitation in Windows. I'd really like for that to be resolved so this utility wouldn't be necessary. But if that isn't going to get resolved, this sort of functionality probably makes a lot more sense to fold into Docker for Windows. Until then, I'll be happy to take pull requests, take on some additional contributors if there's any interest there, or work on cleaning up issues.