Docker Community Forums

Share and learn in the Docker community.

Can't connect to container via localhost


(Samuel88835) #1

On step 5 of https://docs.docker.com/docker-for-windows/
I ran docker run -d -p 80:80 --name webserver nginx

opening up localhost in chrome gave me ERR_CONNECTION_REFUSED

docker ps tells me that the port is still 0.0.0.0:80->80/tcp yet i can’t get to it by localhost

I looked at it on kitematic and the published port was 192.168.99.100:80

http://192.168.99.100:80 got me to the right nginx welcome page

any idea why the container wasn’t on localhost?


(David Maze) #2

Because you’re running Docker Toolbox. If you can’t run the native Docker for Windows, then Docker Toolbox will (via Docker Machine) create a Linux virtual machine that can run Linux containers, and everything published with docker run -p parameters will show up on that VM and not your physical host. That VM almost always is 192.168.99.100.

(P.S.: be careful saying “localhost” around Docker: it does not mean your physical hardware)


(Samuel88835) #3

okay, this makes much more sense now.
I used chocolatey to download docker so I didn’t realize what I got wasn’t native Docker for Windows.

Thanks