From within a container, 127.0.0.1 is always that container itself.
(I guess later on you mention running some containers as --net host
, and there, 127.0.0.1 is the host. But you need to find an IP address for the host and pass it into other-network containers as “the host address” for this sort of use case. In some environments there’s a “normal” IP address you can use, maybe 172.17.0.1 on native Linux and 192.168.99.100 on Docker Toolbox, but there’s not anything fixed for Docker for Mac, and the fixed address may not work on a non-default bridge network.)
(Think of this problem as each container being a physically separate server, and the host is your router.)
If you’re setting up a bridge network anyways, then you should use the built-in Docker DNS service and refer to other containers by their names. Then you won’t be dependent on fixed IP addresses for anything. (They’re a hassle in pretty much any environment.)