Home > OS >  docker container not able to reach some of host's ports
docker container not able to reach some of host's ports

Time:02-18

I have a stack with docker-compose running on a VM.

Here is a sample output of my netstat -tulpn on the VM

Proto Recv-Q Send-Q   Local Address             Foreign Address         State      
tcp        0      0   0.0.0.0:9839              0.0.0.0:*               LISTEN     
tcp        0      0   127.0.0.1:8484            0.0.0.0:*               LISTEN   

The docker is able to communicate with port 9839 (using 172.17.0.1) but not with port 8484.

Why is that?

CodePudding user response:

That's because the program listening on port 8484 is bound to 127.0.0.1 meaning that it'll only accept connections from localhost.

The one listening on 9839 has bound to 0.0.0.0 meaning it'll accept connections from anywhere.

To make the one listening on 8484 accept connections from anywhere, you need to change what it's binding to. If it's something you've written yourself, you can change it in code. If it's not, there's probably a configuration setting your can set.

  • Related