How to serve web server on local IP address using "Docker for Windows"?

I’m serving a simple web server using “Docker for Windows”, by performing a “-p 80:80” but it’s served on the internal virtual address. How can I instead make it serve (like it does on Linux) on the IP running on my machine, so that other machines on my network can access it by accessing my machine’s IP:80 …?

This just works in Linux.

1 Like

I am facing the same problem. Container is only accesible by its virtual address. I am running Docker 1.13 on win 10 64bit Enterprise 1607

1 Like

Hello,

I just tested: docker run -d -p 80:80 httpd

And then in the browser http://localhost and it worked. I have docker for windows 1.12.1 build: 7135

Regards

1 Like

I faced same problem and I solved it using reverse proxy. Windows own system ports like a 80 port, so Docker cannot use it by default. (I didn’t tested administrator mode.)

Here’s my solution.

  1. Install Nginx (or Apache2) on your computer and edit conf for reverse proxy.
  2. Match the docker port to localhost port. (ex: Docker Port -> 80, MAC IP:Port -> localhost:12300)
  3. Happy hacking :slight_smile:

If you want to see screenshots, I’ll upload it. Feel free to asking.

Regards, CHANN.

Make sure you don’t have Skype running in the host system, because it uses port 80 and 403 by default! I had the same issue some time ago. There’s an option to disable port 80 usage though

@ccramirez yes, http://localhost will serve it up just fine. But if you look closer, it’s not serving on the IP address you think.

@fredrikaverpil you are right is not serving the ip from outside. Try this with Elevated Power Shell:

netsh interface portproxy add v4tov4 listenaddress=yourip listenport=80 connectaddress=10.0
.75.1 connectport=80

1 Like

I run the following, container starts
docker run -d -p 8082:80 webapi

but when i hit localhost doesn’t work
http://localhost:8082/api/customers/000000

if i hit containers ip everything works just fine
http://172.25.159.78/api/customers/000000