Accessing docker container IP from a different physical machine

I have a server hosted listening on port 8080 on a docker container running on a boot2docker host in my MAC running Yosemite.

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.

  • Docker Busybox container add groups and user
  • Attack vectors when running untrusted docker images
  • ssh into boot2docker - can you see -v folders from within boot2docker vm
  • Fleetctl job already exists
  • How can I keep a docker debian container open?
  • Build the Node js app on Docker
  • 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 ?

    Thanks !

  • want to use the same host and port for ssh session
  • docker-compose up fails with “UnixHTTPConnectionPool(host='localhost', port=None): Pool is closed”
  • How can I add hostnames to a container on the same docker network?
  • Insecure Docker registry on Centos7 refuses to ingest images, even with flag 'insecure-registries'
  • Go-CD won't npm install
  • crontab not working ubuntu 16.04
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.