6

I have a bunch of servers running in docker containers with docker-for-windows. Because of how docker works on windows these all get shoved inside of hyper-v vm and then the containers run there. So to access a server that is bound to localhost, i actually use the ip of the hyper-v virtual adapter.

enter image description here

enter image description here

enter image description here

So i can connect to my server using 10.0.75.2:3579 when im on the host windows machine. Now i want to user zerotier to bridge all my docker containers to a virtual lan so that i can access my containers outside of my schools network. ZeroTier creates a virtual adapter called "zerotier one virtual port": enter image description here How it works now is that if i run servers on the host windows machine (bare metal) then i can access them using my zerotier ip 10.147.17.221:port. BUT this doesn't connect my docker stuff since its on a different adapter, meaning i must be physically on machine to do any docker related stuff. How do i route or bridge the zerotier adapter to the hyper-v docker adapter so that i can access my docker containers externally using the zerotier ip?

Stephen Eckels
  • 435
  • 6
  • 17
  • I don't have windows to try and do it. Can you select the `hyper-v` adapter and your main Wifi adapter and see if they can be bridged? – Tarun Lalwani Apr 19 '18 at 13:03
  • i've tried this already. The windows briding feature seems broken. When i do this both the hyper-v adapter and the zerotier adapter go down, complaining about 'cable unplugged' – Stephen Eckels Apr 19 '18 at 21:09

3 Answers3

1

I don't have a windows VM to try this out, but would use a docker network for the purpose. For instance:

docker network create private

docker run --rm --name web --network private -p host_port_1:container_port_1 -p host_port_2:container_port_2 nginx:latest

docker run --rm --name db --network private -p host_port_3:container_port_1 -p host_port_4:container_port_2 postgres:latest

Let me know how it goes.

Community
  • 1
  • 1
Timir
  • 1,395
  • 8
  • 16
  • docker networks exist inside the vm and so are still on the other adapter. So this doesn't work. I've also tried the l2bridge and transparent network types described here: https://4sysops.com/archives/windows-docker-networking-part-2-custom-network-types/ and here: https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-networking but those aren't supported in linux container mode. So i can only create the default NAT network type. I can do "host" networks too but those are bound to the VM's host network, none of these allow me to escape the vm – Stephen Eckels Apr 23 '18 at 01:24
0

Best solution i've come up with is to not use zerotier. I've switched to ngrok which allows redirection to local ip's trivially

Stephen Eckels
  • 435
  • 6
  • 17
0
  • Create a Managed Route like this on your ZeroTier network: [10.0.75.0/24] - [10.147.17.211]
  • Turn on IP Forwarding in Windows.

This will add a static route to all the ZeroTier nodes on your network so they know to use your VM hhost's zerotier IP as the route to the docker LAN.

tladuke
  • 1,337
  • 2
  • 11
  • 22