0

I follow the tutorial at https://code.visualstudio.com/docs/containers/quickstart-aspnet-core and successfully run http://localhost:5000/WeatherForecast which return the web api data.

[{"date":"2020-07-17T04:41:37.661625+00:00","temperatureC":41,"temperatureF":105,"summary":"Cool"},{"date":"2020-07-18T04:41:37.6633079+00:00","temperatureC":24,"temperatureF":75,"summary":"Sweltering"},{"date":"2020-07-19T04:41:37.6633109+00:00","temperatureC":49,"temperatureF":120,"summary":"Scorching"},{"date":"2020-07-20T04:41:37.6633112+00:00","temperatureC":-9,"temperatureF":16,"summary":"Hot"},{"date":"2020-07-21T04:41:37.6633114+00:00","temperatureC":40,"temperatureF":103,"summary":"Bracing"}]

My question is how do I access to docker's IP address instead of localhost? When I right click the Containers in VSCode and click Inspect, there is "IPAddress": "172.17.x.x". But when I go to http://172.17.0.2:5000/WeatherForecast, it returns with an error

This site can’t be reached
172.17.x.x took too long to respond.
Steve
  • 2,963
  • 15
  • 61
  • 133
  • 2
    `172.17.x.x` is the IP inside the docker environment. other images in the docker environment in the virtual network can reach it with that IP. From your host machine, you'll need to contact it with `localhost` – Foo L Jul 16 '20 at 05:45
  • 1
    Check this answer, it might help. https://stackoverflow.com/a/25041782/6332074 In case you're using Windows then run ipconfig instead of ifconfig. – Muhammad Waqas Dilawar Jul 16 '20 at 05:51

0 Answers0