Docker Community Forums

Share and learn in the Docker community.

How to access container IP address from the host OS

This networking question crosses dockers and vagrant.
My OS is Windows10 with HyperV disabled. My setup is Wins10 -> Vagrant/VirtualBox -> Docker
I have setup a private network address in my vagrantfile: and I have forwarded ports to map the ports between Host OS (Win10) and the Guest OS (Ubuntu) in my vagrantfile.
I am able to run the container services and I can from Windows Host access the container app using the above private network address.
But the container app has no data.
I want to push data from an app located on Windows (appA) to the docker container app. I failed to achieve that.
I had tried command line app to push data to the docker container app. It also failed.
The same command line app however, has no problem to push data to the above app (appA) sitting on the Window host.
When I inspect the docker network Vagrant created, I can see the IP addresses each of the container services is assigned. But these are internal IPs to docker or to guest OS (Not sure which!). I can’t ping these IPs from Windows host.
Can someone please advise me how to access the containers from the host? What IP should I use? Can someone give me reference URLs that address this communication issue?
I have read the networking pages from Vagrant, Dockers and tried out all the options. Nothing is working so far.
Thanks in advance.

One more thing.
In my setup, I had forwarded the ports used by the docker container app to the host OS in my vagrantfile and I had opened up these host ports on my Windows’ firewall.

Your description seems like you use a nat interface.

Since you already took care of the firewall, the whole process should be easy:
1… Publish container ports to “host” ports in vm guest
2. Bind the published vm guest ports on your Windows hosts ports

Then access your service on the host using localhost:{host port}.

People that try to access a container by its ip usaly try to do something in a way it is not intended to. Always publish ports and access a service inside a container using the docker host’s hostname or ip and the published port. In your case there is just another level of port forwarding involved.