Docker Community Forums

Share and learn in the Docker community.

Not able to telnet external DB server from Docker Swarm-single Node but running good on NAT network

docker --version
Docker version 18.09.2, build 6247962

On Window10, running dockers in windows container.

I have recently starting working on Dockers .

Requirement:
I am trying to run a jar file inside docker swarm single node and then replicate it .

This jar file open service at 5012 port and connects to external DB server on IP: xx.xx.xx.xxx:1433 .[ this db server is not running on docker]

Running this on docker container over the NAT network , works perfectly fine
docker run -p 8080:5012 abc:v1.

but while using the same dockerfile when I tried to run under single node docker swarm , connection times out while trying to connect to IP: xx.xx.xx.xxx:1433
Error: com.inet.tds.Tds4SQLException: [TDS Driver]java.net.ConnectException: Connection timed out: connect

Command used:
Docker service create -p 8080:5012 --replicas 3 --name test1 abc:v1.

docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
p6eaaek4zz8pmmfvr2z7i5dtz * ATLPWCQA01 Ready Active Leader 18.09.2

I am having the same problem, unfortunately I haven’t found a solution yet.

The problem is because you can only use swarm scoped networks from services in a swarm. So when you create your service, an overlay driver is created to allow communication between services in the swarm. Unfortunately, on Windows there is no bridge between the overlay network and the swarm node’s host network and as such there is no external network access. In the Microsoft documentation, see https://docs.microsoft.com/en-us/virtualization/windowscontainers/container-networking/network-drivers-topologies they state the following for container to external network access for the overlay driver: “Not directly supported - requires second container endpoint attached to NAT network”. However, after hours of trial and error, also scouring the internet and various forums, I cannot find a way to add a second container endpoint, as swarm services won’t allow a local scope network to be added.

This seems like a massive problem and a deal-breaker for me. External network would be an essential requirement for the gradual migration of brown-field applications to containers and also for implementing any application that requires access to 3rd Party services outside of the swarm.