Answer the question
In order to leave comments, you need to log in
How to make Windows see the network from WSL2 in host mode?
An interesting feature, the solutions of which have not yet been found (and such a question has arisen on the network more than once, for example ). If the machine is inside WSL2, let's say Ubuntu under Windows, and create a container with an open port, it is accessible from Windows, but if you make the host mode, Windows does not see the created network point-blank. For example, this will open localhost on Windows:
containers:
nginx:
image: nginx:latest
ports:
- '80'
containers:
nginx:
image: nginx:latest
network_mode: host
expose:
- '80'
Answer the question
In order to leave comments, you need to log in
This problem does not have an adequate solution. Docker for Windows has a special implementation, its own network, and host mode means that the application will not run on the WSL2/Windows network, but on Docker's own network. Whereas opening ports creates tunnels for WSL2 and Windows networks. The only way to get this to work is to manually tunnel each time you start containers, which is hardly an easy thing to do because, again, according to the documentation "This interface is actually within the virtual machine".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question