Docker Community Forums

Share and learn in the Docker community.

Docker Desktop - Can't connect to internal Network

Hello. I use DOCKER Desktop and I have a portainer app with a SQL connection String, but it won’t connect to the internal network. I can telnet from within docker to the SQL Server and I’m certain that my SQL Config is setup correctly to allow remote connections on port 1433.

I can get this to work from within the machine that has Docker installed/SQL Express. The issue has to be a network related issue…

I can ping the SQL server just fine…

Any idea’s on how to get Docker Desktop to “see” the internal network? Windows Firewall is turned OFF. I don’t know what else to do to get this to work.

My internal IP range is 10.10.x.x. and the Docker network is using these settings. I’ve already tried setting the Docker Desktop>Network DNS to my Servers DNS.

Any info on how to resolve this is greatly appreciated.

Or is my connection string on my container wrong? It shouldn’t be…

I think THIS is the issue, but not sure why?! I’m erasing the actual credentials for obvious reasons.
SQLCONNSTR
server=192.168.1.1\MSSQL2014;database=db;User ID=user;Password=pw

I’m also using Postman to send an authentication request …

THANKS IN ADVANCE!!!

Following is a summary of current limitations on the Docker Desktop for Windows networking stack, along with some ideas for workarounds.

There is no docker0 bridge on Windows
Because of the way networking is implemented in Docker Desktop for Windows, you cannot see a docker0 interface on the host. This interface is actually within the virtual machine.

I cannot ping my containers
Docker Desktop for Windows can’t route traffic to Linux containers. However, you can ping the Windows containers.

Per-container IP addressing is not possible
The docker (Linux) bridge network is not reachable from the Windows host. However, it works with Windows containers.

Use cases and workarounds
There are two scenarios that the above limitations affect:

I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST
The host has a changing IP address (or none if you have no network access). We recommend that you connect to the special DNS name host.docker.internal which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Windows.

You can also reach the gateway using gateway.docker.internal.

If you have installed Python on your machine, use the following instructions as an example to connect from a container to a service on the host:

Run the following command to start a simple HTTP server on port 8000.

python -m http.server 8000

If you have installed Python 2.x, run python -m SimpleHTTPServer 8000.

Now, run a container, install curl, and try to connect to the host using the following commands:

$ docker run --rm -it alpine sh

apk add curl

curl http://host.docker.internal:8000

exit

I WANT TO CONNECT TO A CONTAINER FROM WINDOWS
Port forwarding works for localhost; --publish, -p, or -P all work. Ports exposed from Linux are forwarded to the host.

Our current recommendation is to publish a port, or to connect from another container. This is what you need to do even on Linux if the container is on an overlay network, not a bridge network, as these are not routed.

The command to run the nginx webserver shown in Getting Started is an example of this.

$ docker run -d -p 80:80 --name webserver nginx
To clarify the syntax, the following two commands both publish container’s port 80 to host’s port 8000:

$ docker run --publish 8000:80 --name webserver nginx

$ docker run -p 8000:80 --name webserver nginx
To publish all ports, use the -P flag. For example, the following command starts a container (in detached mode) and the -P flag publishes all exposed ports of the container to random ports on the host.

$ docker run -d -P --name webserver nginx

1 Like