Docker Community Forums

Share and learn in the Docker community.

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


(Fredrikaverpil) #1

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.


(Xalikoutis) #2

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


(Crramirez) #3

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


(Channprj) #4

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.


(Qbprog) #5

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


(Fredrikaverpil) #6

@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.


(Crramirez) #7

@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


(Xalikoutis) #8

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