My docker container does not start on localhost (0.0.0.0) on Docker for Windows (native, using Hyper-V)

I am following a digital ocean tutorial on how to run the nginx docker container (currently in step 4). This is currently their conclusion:

$ docker run --name docker-nginx -p 80:80 -d nginx d3ccb73a91985651ec61231bca9f9c716f0dec807e354a29eeef2144f883a01c $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b91f3ce26553 nginx "nginx -g 'daemon off" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 443/tcp docker-nginx 

But when I run it, this is my output (noticed a different IP address of the container):

 C:\>docker run --name docker-nginx -p 80:80 -d nginx d3ccb73a91985651ec61231bca9f9c716f0dec807e354a29eeef2144f883a01c C:\>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d3ccb73a9198 nginx "nginx -g 'daemon off" 14 hours ago Up 2 seconds 10.0.75.2:80->80/tcp, 443/tcp docker-nginx 

Why is this happening? And how can I get the same results as Digital Ocean? (Getting the server to run on the local host)


Change I am using Docker for Windows (recently released) which apparently works using Hyper-V. My output for docker-machine ls is this:

 C:\>docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS C:\> 
+6
source share
2 answers

But when I run it, this is my output (noticed different IP addresses of the container)

Since this is a Windows machine, I assume that you are using the Docker Toolbox Docker for Windows. 10.0.75.2 is the IP of the virtual machine boot2docker .

If you are using Windows or Mac OS, you will need a virtualization form in order to run Docker. The IP address you just saw is the IP address of this lightweight virtual machine.

And how can I get the same results as Digital Ocean? (Getting the server to run on the local host)

Use the Linux distribution! You can also enable Expose container ports on localhost in Docker for Windows Settings:

enter image description here

+10
source

Despite the fact that you created containers on your local computer. They actually work on another machine (virtual machine)

First check what the IP address of your docker machine (virtual machine) is

 $docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM default * virtualbox Running tcp://192.168.99.100 

Then run the curl command (or open a browser) to view the default website on the nginx web server inside the container

 curl http://192.168.99.100:80 
+6
source

All Articles