Last active
July 5, 2023 03:36
-
-
Save schmich/ab42d1e094c35fd0b444768841a696d9 to your computer and use it in GitHub Desktop.
Forward external connections to Docker on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM In admin prompt | |
REM Ensure web server/application is listening on all interfaces (0.0.0.0) | |
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=80 connectaddress=10.0.75.2 connectport=80 | |
netsh advfirewall firewall add rule name="App" dir=in action=allow protocol=TCP localport=80 remoteport=80 | |
netsh interface portproxy show v4tov4 | |
netsh advfirewall firewall show rule "App" | |
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=80 | |
netsh advfirewall firewall del rule name="App" | |
netsh interface portproxy show v4tov4 | |
netsh advfirewall firewall show rule "App" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is looking for trouble. Portproxy spawns svchost which binds IP/PORT. If you bind portproxy to 0.0.0.0, next time your docker frees 10.0.75.2:80 svchost will hog it. At least that is how it works in Windows 10 Pro 22H2 19045.3086 and if you try to start docker again it will fail to bind the port as wslrelay (default docker backend is WSL) will silently fail to bind the port.
You better off having docker forwarding other port than 80 and portproxy to that port.