Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Route/Bridge docker virtual adapter with zerotier virtual adapter

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?

like image 382
Stephen Eckels Avatar asked Apr 16 '18 16:04

Stephen Eckels


1 Answers

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.

like image 148
Timir Avatar answered Oct 13 '22 20:10

Timir