0

As far as I know, by default, Docker binds to 127.0.0.1 when running docker compose with the default network settings. To access my containers, I need to map alternate ports to access them through localhost, such as 45001:80 to access my web server container from the host.

I would like to bind my containers to an alternate IP then 127.0.0.1 on my machine so I can use the proper ports instead of having to forward the ports through localhost. For example, to access my web server container, instead of going to 127.0.0.1:45001, I would bind to something like 192.168.0.1 and access it via 192.168.0.1:80. I've tried searching for an answer for this, but I can't seem to find it. Going through the Docker documentation hasn't gotten me terribly far either.

Anybody know how I would accomplish this?

Frank Rosario
  • 2,512
  • 5
  • 31
  • 47
  • You would probably need bridge network if you want to host it on the same network https://learn.microsoft.com/en-us/virtualization/windowscontainers/container-networking/network-drivers-topologies – Gregory Suvalian Jan 10 '19 at 20:07
  • You can explicitly specify the bind address in the [docker-compose `ports:` directive](https://docs.docker.com/compose/compose-file/#ports), and it's documented as defaulting to 0.0.0.0 (reachable on all interfaces). – David Maze Jan 11 '19 at 00:12

0 Answers0