1

I have a docker-compose.yml file, that defines three services, using shared network. Network is defined only by name. docker network list shows that it's a bridge network. docker inspect network gives the IP addresses (172.23.0.x, with 172.23.0.1 defined as a gateway). My understanding is that this gateway is my Docker host (a Windows 10 machine).

When I execute wget http://containerA-ip:PORT// from bash running in containerB, I get response alright.

When I execute wget http://gateway-ip:PORT// from bash running in containerB, I get response alright, too. (port PORT is published as PORT:PORT, so I assume that's the reason it works).

BUT. If I try to wget http://gateway-ip:OTHER-PORT, where OTHER-PORT is a port number of some process that is listening on my Windows 10 machine, I get Connection refused.

I wonder, is it FW configuration on my Windows machine, that's preventing this connection, or is it some Docker configuration/implementation detail that's preventing this kind of connection.

I was unable to find an answer to "how to connect to Docker host services from within a container using bridge network" anywhere in the documentation..

Thanks to anyone, who could assist.

UPD: I've been suggested to check which interfaces this service is listening on, here's the output of netstat -na | grep 8088:

TCP    0.0.0.0:8088           0.0.0.0:0              LISTENING                                                                                                                      
TCP    [::]:8088              [::]:0                 LISTENING          

to verify it's the case, I've run curl --noproxy "*" -X POST "http://192.168.0.13:8088/" and it produced expected response

62mkv
  • 1,444
  • 1
  • 16
  • 28
  • 'Connection refused' tells you that the connection was established, but the remote host wasn't listening on the port you were trying to reach. Check if the service you are trying to reach is listening for any IP (`0.0.0.0`) and not loopback interface (`127.x.x.x`). – anemyte Feb 26 '21 at 13:25
  • I've edited the question to add this information – 62mkv Feb 26 '21 at 13:35
  • Are you using Docker Desktop for Windows or docker-ce via WSL? – anemyte Feb 26 '21 at 13:41
  • Docker Desktop, no WSL (i.e. with Hyper-V) – 62mkv Feb 26 '21 at 13:45
  • Try temporary disabling firewall if you still hadn't. No idea what else it could be. – anemyte Feb 26 '21 at 13:52
  • 1
    On Docker Desktop (MacOS or Windows), use the special hostname `host.docker.internal`. Don't bother looking up the container-private IP addresses. – David Maze Feb 26 '21 at 14:10
  • David Maze, can you provide an answer ? THIS WORKS!!!!!! – 62mkv Feb 26 '21 at 15:31
  • sorry, should have used mentions: @DavidMaze – 62mkv Feb 26 '21 at 15:37

0 Answers0