network-programmingdockertelnetiptablestutum

Outbound telnet connection from Docker container refused but works fine on host


I'm facing a network issue on a node hosted via Tutum to AWS.

I sshed into the node and ran

telnet localhost 3000

and it works great. When I docker exec -it <containerid> bash into one of my containers and run the same command above and I get this error:

telnet: Unable to connect to remote host: Connection refused

Can anyone shed some light as to why outbound connections from container to host is not permitted?


Solution

  • What network stack are your containers using? localhost mean local. On your host it is the host-local-interface, your containers it is their own host-local-interface. So unless you run your containers with --net=host it is a regular behavior since there is no service running on containers-localhost-ip:3000 but only on host-localhost-ip:3000 which are different.