Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not access nginx container on a local windows machine

Tags:

docker

nginx

I'm running an nginx container on a windows 10 machine. I've stripped it down to a bare minimum - an nginx image provided in the Docker hub. I'm running it using:

docker run --name ng -d -P nginx

This is the output of docker ps:

b5411ff47ca6 nginx "nginx -g 'daemon off" 22 seconds ago Up 21 seconds 0.0.0.0:32771->80/tcp, 0.0.0.0:32770->443/tcp ng

And this is the IP I'm getting when doing docker inspect ng: "IPAddress": "172.17.0.2"

So, the next thing I'm trying to do is access the Nginx server from the host machine by opening http://172.17.0.2:32771 in browser of the host machine. This is not working (host not found etc).

Please advise

like image 448
MeLight Avatar asked Apr 07 '16 13:04

MeLight


2 Answers

  1. Follow this article... https://docs.docker.com/get-started/part2/#run-the-app
  2. And make sure your application is running not just docker.

docker run -d -p 4000:80 friendlyhello

After this on Windows 10 host machine

  1. Worked http://192.168.99.100:4000/
  2. Not working: http://localhost:4000/
like image 165
Nikhil Pingle Avatar answered Oct 29 '22 22:10

Nikhil Pingle


On windows, you are using Docker Toolbox, and the IP you need is 192.168.99.100 (which is the IP of the Docker Toolbox VM). The IP you got is the IP of the container inside the VM, which is not accessible directly from Windows.

like image 37
Xiongbing Jin Avatar answered Oct 29 '22 22:10

Xiongbing Jin