osx - How to access webserver running on localhost from a docker container on a network? -


i have following system configuration:

  • docker container running on user defined network
  • docker-machine (with virtualbox on os:x forwarding port 9000 9000)
  • local webserver running on http://localhost:9000

i not know how make basic http request against webserver, within docker container.

to test using:

docker exec testcontainer curl --data "foobaz=foo" http://{hostname}:9000/ 

where have tried, hostnames:

  • 'localhost'
  • '127.0.0.1'
  • '192.168.99.100' (docker-machine ip)

each time receive errors or timeouts. when run curl command locally (not in docker , on host os:x machine) able post http request.

i cannot disconnect docker container user-defined network. cannot add webserver to network, not running in container. also, know trivial connect other way (curl webserver running in docker container) not use case.

how can route http request docker container part of user defined network localhost webserver?

you can actual ip address of local computer.

so example, if en0 ip 10.100.20.32 on host os, can run:

docker exec testcontainer curl --data "foobaz=foo" http://10.100.20.32:9000/ 

which allow make http requests.

note if doing container on host docker network, trivial, can directly access localhost or 0.0.0.0 without having use actual machine ip.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -