I want to enable a docker VM to connect to a port on the localhost of the host starting docker on windows.
docker proposes port forwarding but IMHO only to expose a docker’s VM port to the host running the VM.
It’s also possible to map a hostname to an IP address when starting docker, but again, that is only seen on the VM.
So neither of the following options help:
My current purpose is to expose the XServer port running on the Windows host to the VM . My current solution is to find a Windows host IP, but when the network changes that IP is no longer valid and the XServer is apparently not listening on the new IP.
This happens when the computer hibernates and is on a new network when it wakes up.
ssh provides the
-R options that allows to forward an IP/port either way.
A possible solution could be to start the container in detached mode,
ssh to it and setup the port forwarding, and do all the other work in another
Another possible solution is to setup a NAT server (I didn’t try).
host.docker.internal in the VM may be a solution – I start testing this to see if it holds over time. It does work for the initial connection (I set DISPLAY to
host-gateway may need more investigation).
Run without isolation (option
--net host). Not tested.
So my question is, what method(s) are there to allow the docker VM to access a port on the Windows HOST’s localhost addresses (127.0.X.X) .
A less general question is: how to setup the DISPLAY/Xserver on a Windows host and docker runs so that they always work, even after changing networks.
Note that my host OS is Windows 10 (this might be easier to do on *nix).
Source: Docker Questions