Question about Private Network IP defined in a Vagrantfile

16 views
Skip to first unread message

Sorcerer Stone

unread,
Apr 3, 2020, 3:43:15 PM4/3/20
to Vagrant
Hello all,

I am using Win10Pro with HyperV deactivated.
I am running a vagrantfile that calls a docker compose file and setting up & running docker services (from a Github open source module). In my vagrantfile, I setup a private_network address: 192.168.33.10
Currently, all the requires container services are running. There is a docker network setup by the vagrantfile namely "vagrant_default".
I used docker inspect to look at this vagrant_default network. I can see the subnet & gateway for this vagrant network. I can see the IP addresses of all these container services running. For example:

"Name": "vagrant_default", ...
"IPAM": {
...
  "Config": [
    {
      "Subnet": "172.18.0.0/16",
      "Gateway": "172.18.0.1"
    }
  ]
},
...
"Containers": {
  "1b3e1e8662ee8456368b720e781d324de063147bbe26d13876e2581d7e27fbc4": {
  "Name": "AppDock01",
...
  "IPv4Address": "172.18.0.2/16","IPv6Address": ""
  },
...

I pinged the private_network address, 192.168.33.10, defined in the vagrant file from Windows host OS. I got response.
I pinged the container "AppDock01" ip address defined above: 172.18.0.2 from the Windows host. I got timed out msg. Ping failed. I understand these internal IPs are for inter-containers communication.

I have an app (AppHost) sitting in the host environment.
"AppHost" wants to communicate with one of the running docker services "AppDock01" inside the guest OS. To do that, "AppHost" needs the IP address, port # (plus others IDs) of "AppDock01".
On the docker side, I have to tell "AppDock01" to accept the data coming from the IP address, port # (plus other IDs) of "AppHost".


Q1/ "AppHost" on host OS needs the IP address of "AppDock01" on the guest OS side, what IP address should I use?
In the extract above, I know for the container "AppDock01", the internal IP is 172.18.0.2. From the vagrantfile, the internal network IP (defined in vagrantfile) is 192.168.33.10. I can ping 192.168.33.10 from the host but not 172.18.0.2

Q2/ "AppDock01" on the guest OS side needs to know the IP address of "AppHost". In the host environment, "AppHost" has an IP address say 192.168.1.10. Can the docker container, "AppDock01", inside the guest OS see this IP address on the host (aka 192.168.1.10)? If not, what should I do to set up an IP address for "AppHost" so that "AppDock01" can see?

Summarized: My current work environment is Win10 (HyperV disabled) -> Vagrant/VirtualBox -> Docker

Thanks in advance.
Reply all
Reply to author
Forward
0 new messages