Docker Community Forums

Share and learn in the Docker community.

Can't connect to out port from container

Hello everyone!

I have a machine running docker container.
At real machine, I could telnet to remote_host:post but inside container, I can’t connect or telnet to that remote_host:post

Anyone can explain me how is it? I have opened all rules in iptables.

So the problem can be broken down to the following steps:

Check the docker inspect or docker ps results to ensure that you have your port exposed correctly
Try to connect to it using the public IP. If you got an error message for example

Connection Refused: The reason could be because the application inside the container is not running as expected. for example you need to ensure that the application bind to 0.0.0.0 and not 127.0.0.1

Connection Timeout: The reason could be a firewall outside the server like SecurityGroups in AWS or similar or maybe docker is not managing the server firewall (which is not the default setup)