Docker Community Forums

Share and learn in the Docker community.

Docker-compose port-to-IP binding under Windows


(FLI) #1

Hello,

At work I’m the black sheep running Windows when all my colleagues are using Mac or Ubuntu. One thing that they do in their dev machine docker-compose configs doesn’t work under Windows:

    ports:
    - "127.0.0.1:80:80"
    - "127.0.0.1:443:443"

The purpose of adding the IP to the ports is, as far as I understand it, to limit access to these ports to only the host machine, preventing the local dev apache server from being exposed to the public if you connect your wifi to an untrusted network. And that’s the effect I’m looking for, only exposing the apache running in my container to the windows host, it’s a development environment and that’s all I need. That and security.

How would I accomplish this on Windows? I’ve tried binding to both 127.0.0.1 and 10.0.75.1. In both cases the web server becomes unreachable from the host. (it only works as long as I specify no IP at all)

I’ve also tried to search for a solution online but I may be using the wrong keywords, because I haven’t found anything that addresses this particular situation.

Best,
Fredrik


(Tekki) #2

You don’t want to tell us that you connect your Windows machine to untrusted networks and have no firewall running? :wink:


(FLI) #3

Oh, that’s helpful. Really. Wow.


(Tekki) #4

Sorry, it was just a joke.
So to get a real answer I’ve changed the ports section in one of my compose files using httpd to “127.0.0.1:80:80” and it works perfectly. I should mention that I’m on Docker Desktop 2.0.2.0.

Edit: It uses adminer, not httpd.