Unable to connect to remote SQL server from container Unable to connect to remote SQL server from container docker docker

Unable to connect to remote SQL server from container


Docker Bridge networks don't connect to the world outside of Docker at all by default; they only allow containers to talk to each other. The documentation for Docker Bridge Networks does offer some advice for allowing Bridge network traffic to talk to the outside world by making changes on the Docker host:

First enable IP forwarding in the kernel:

$ sysctl net.ipv4.conf.all.forwarding=1

Then change the host firewall to allow the forwarding

$ sudo iptables -P FORWARD ACCEPT

This is a fairly permissive firewall configuration, so you may want to look at keeping that a bit more locked down.

The other way would be to attach the container to two different networks: your current bridge network for communication between container, and a second Host network for talking to MySQL. Since this bypasses all of Docker's NAT configuration, the scalability of your service may be impacted, although I think outgoing connections might be OK.


For my case:I ran these below:

To see all containers:

docker ps -a

Then restart container:

docker container restart yourIdContainer

If there is error: Error response from daemon: Cannot restart container ...

Please restart Docker then restart container again.

Connect to Sql Server by MSSM, server name: localhost,1433 or IP

Hope this is helpful.


If you are using Windows 10 (HOME VERSION ) may you don't have the virtualization and you are using (docker toolbox ), they have solved the problem using a static ip. Check it. I mean localhost won't work if you are using docker toolbox, search the ip where is virtualized docker toolbox.

My case ip: 192.168.99.100