Question about private network IP address in a vagrantfile

34 views
Skip to first unread message

Sorcerer Stone

unread,
Apr 2, 2020, 3:04:38 PM4/2/20
to Vagrant
My host network is Win10 pro with HyperV disabled. I am trying to run docker projects using vagrant. Have a question about networking in docker but it sort of involving docker and vagrant. Hope someone may help.
In my vagrantfile, I created a private network with an ip:

config.vm.network "private_network", ip:"192.168.33.10"

I also instructed the vagrantfile to install ubuntu. Once the ubuntu is installed, I created a network for the particular open source project I want to run.

For example: docker network create mybridgenetwork

When I inspect this network, I found something perplexing. There is a segment in the config file that said this:

...
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
...

On my windows host, I tried to ping 172.18.0.0 or 172.18.0.1, I got no response.
When I pinged the private network specified in the vagrantfile, I got reply.

So, when I try to run a yml compose file using vagrant, I should use the private IP stated in the vagrantfile (192,168.33.10) and not the gateway's address 172.18.0.1

Am I correct?

What is the relationship between 172.18.0.1 (the IP of the docker network gateway) and 192,168.33.10 (the private network IP stated in my vagrantfile)?

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