I’m trying to connect to service running on the host machine from within the Docker container. According to the documentation there are two special hostnames I can use to target the host machine.
host.docker.internal
gateway.docker.internal
When I try to resolve them the container doesn’t recognise them:
C:\Windows\System32>docker container exec d6 cmd /C nslookup host.docker.internal
*** UnKnown can't find host.docker.internal: Server failed
Server: UnKnown
Address: 172.19.48.1
C:\Windows\System32>docker container exec d6 cmd /C nslookup gateway.docker.internal
Server: UnKnown
Address: 172.19.48.1
*** UnKnown can't find gateway.docker.internal: Server failed
I need to use them as part of a connection string:
Data Source=tcp:host.docker.internal;Initial Catalog=MyDatabase;User ID=Dave;Password=Password;
Any idea what I’m doing wrong/not doing at all?
Here’s my Docker details:
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:12:48 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.24)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:21:42 2018
OS/Arch: windows/amd64
Experimental: false