Accessing docker container IP from a different physical machine
If I try to curl the boot2docker IP on port (say 8080) from my machine, I am able to hit the server running in docker container and get the response back.
What I am interested in doing is that I want to send a request from another machine to this server and get the response back. I tried to add a port forwarding rule using pfctl but that doesn’t seem to work. When I execute the following command on my machine –
tcpdump -pnti en0 tcp port 8080
and do a curl on my machine’s IP , I see that something is listening on port 8080 but no response comes back. We have this 2 levels of hierarchy here – my physical machine, the boot2docker running on a box and the docker container running the server. How could I achieve this task of sending request of one machine to another machine having the server in a docker container ?
One Solution collect form web for “Accessing docker container IP from a different physical machine”
I was able to forward the request coming from another machine but within the same network using this command –
boot2docker ssh -vnNTL <1st Physical Machine IP>: Any Port :
boot2docker IP or localhost>: Host port mapped to container’s port
Example – boot2docker ssh -vnNTL 192.168.1.2:5000:localhost:32768
Here , I can send a request from any physical machine like –
curl http://192.168.1.2:5000 which will forward the request to my boot2docker’s IP where the container can serve the request and send back the appropriate response and you should see it on the machine where you sent the request from.