Hi
Hope to find some help here.
I’m trying torun a windows container on my windows machine. and would like to connect to it via localhost.
For example the container below.
docker run -d -p 8000:80 --name demo microsoft/dotnet-samples:aspnetapp_
I would like to be able to access it via chrome on http://localhost:8000 i can see the container is starting and output is written in the console but windows i can’t get a site using localhost. If I use the container ip then it works just fine.
Can u explain me in detail coz i am experiencing the same issue…I dont get what a container ip is?are u talking about the ip displayed at the top of docker toolbox as container’s ip?
Note that you can’t connect to that IP address from another host and it’s not constant if a container stops and restarts. There are better ways to reach a container (using docker run -p to publish a port on the host; using Docker’s internal DNS service to communicate between containers).
In short: I’d suggest never running docker inspect to find a container’s private IP address: it’s just not useful.
If you’re using Docker Toolbox then any port you publish with docker run -p will be published on the Toolbox VM’s private IP address. docker-machine ip will tell you. It is frequently 192.168.99.100.
This isn’t prominent in Docker’s documentation, but it does at least show up in the excellent Get Started, Part 2: Containers tutorial. (I couldn’t find this rather important note anywhere around Toolbox Overview, for instance.)
Thank you for ur response David Maze…The actual problem i am encountering is that i have containerized a simple basic php app just with a echo"hello world".It is containerized and is listed with docker ps…Now when I tried to view it uing 192.168.99.100:8080 it says “refused to connect” or “forbidden”…So what am i missing…
I see you found a solution that works.
For others, something to try, is to disable IIS on the host machine (when doing local development).
that fixed a similar issue that I experienced when setting up my first containers
If you’re using (Docker Toolbox), then any port you publish with (docker run -p) will be published on the Toolbox VM’s private IP address. Command (docker-machine ip) will tell you the correct IP address to use. It is frequently 192.168.99.100. Then you can browse to (192.168.99.100:8080) instead of (localhost:8080).