docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.86k stars 292 forks source link

Container can not resolve docker.for.win.localhost #1764

Closed christiansparre closed 6 years ago

christiansparre commented 6 years ago

Expected behavior

I should be able to access host from container on docker.for.win.localhost

Actual behavior

The container can not resolve docker.for.win.localhost

I can access the host on the host IP just fine, but it will not resolve docker.for.win.localhost

I have tried on both stable and edge with same result, I have also tried the "WindowsContainerNetworking-LoggingAndCleanupAide.ps1 -Cleanup -ForceDeleteAllSwitches" tool, but I still can't get it to resolve docker.for.win.localhost in my containers

I have no idea where to look next

Information

Diagnostic id: F54F9478-766E-480A-86CB-F83D87EF565A/2018-02-28_22-41-16

ping & ipconfig

C:>ping docker.for.win.localhost Ping request could not find host docker.for.win.localhost. Please check the name and try again.

C:>ipconfig /all

Windows IP Configuration

Host Name . . . . . . . . . . . . : 424b7e51e57a Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Ethernet:

Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft Hyper-V Network Adapter Physical Address. . . . . . . . . : 00-15-5D-ED-42-D0 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::e995:9b3f:da1b:4cce%4(Preferred) IPv4 Address. . . . . . . . . . . : 172.26.90.197(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.240.0 Default Gateway . . . . . . . . . : 172.26.80.1 DHCPv6 IAID . . . . . . . . . . . : 67114333 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-22-28-D9-91-00-15-5D-ED-42-D0 DNS Servers . . . . . . . . . . . : 172.26.80.1 172.20.91.10 8.8.8.8 NetBIOS over Tcpip. . . . . . . . : Disabled

Debug-ContainerHost.ps1 output, all green

Checking for common problems Container Host OS Product Name: Windows 10 Enterprise Container Host OS Build Label: 15063.0.amd64fre.rs2_release.170317-1834 Describing Windows Version and Prerequisites [+] Is Windows 10 Anniversary Update or Windows Server 2016 102ms [+] Has KB3192366, KB3194496, or later installed if running Windows build 14393 19ms [+] Is not a build with blocking issues 25ms [+] Has 'Containers' feature installed 45.2s Describing Docker is installed [+] A Docker service is installed - 'Docker' or 'com.Docker.Service' 35ms [+] Service is running 19ms [+] Docker.exe is in path 4.17s [+] Docker is registered in the EventLog service 20ms Describing User has permissions to use Docker daemon [+] docker.exe should not return access denied 26ms Describing Windows container settings are correct [+] Do not have DisableVSmbOplock set to 1 27ms [+] Do not have zz values set 25ms [+] Do not have FDVDenyWriteAccess set to 1 23ms Describing The right container base images are installed [+] At least one of 'microsoft/windowsservercore' or 'microsoft/nanoserver' should be installed 254ms Describing Container network is created [+] At least one local container network is available 1.9s [+] At least one NAT, Transparent, or L2Bridge Network exists 53ms [+] NAT Network's vSwitch is internal 34ms [+] A Windows NAT is configured if a Docker NAT network exists 73ms [+] Specified Network Gateway IP for NAT network is assigned to Host vNIC 36ms [+] NAT Network's internal prefix does not overlap with external IP' 23ms

docker info

Showing output from: docker info Containers: 2 Running: 2 Paused: 0 Stopped: 0 Images: 45 Server Version: 18.03.0-ce-rc1 Storage Driver: windowsfilter Windows: Logging Driver: json-file Plugins: Volume: local Network: ics l2bridge l2tunnel nat null overlay transparent Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog Swarm: inactive Default Isolation: hyperv Kernel Version: 10.0 15063 (15063.0.amd64fre.rs2_release.170317-1834) Operating System: Windows 10 Enterprise OSType: windows Architecture: x86_64 CPUs: 8 Total Memory: 15.91GiB Name: EC141 ID: SXTX:VGFO:ZV74:XVSR:PM3G:5BGT:XS7B:OHME:KLU4:XYRL:6HO3:U7WV Docker Root Dir: C:\ProgramData\Docker Debug Mode (client): false Debug Mode (server): true File Descriptors: -1 Goroutines: 50 System Time: 2018-02-28T22:48:05.019761+01:00 EventsListeners: 1 Registry: https://index.docker.io/v1/ Labels: Experimental: true Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false

Kesmy commented 6 years ago

I'm on Edge, and host.docker.internal also doesn't resolve in a Windows container.

christiansparre commented 6 years ago

Yeah, I have been experimenting with this over the last few days. Having tried on a completely new Windows installation, and on an Azure Windows 10 machine.

To me it seems that docker.for.win.localhost only works on Linux containers. If this is the case the documentation and release notes needs to be way better, because nowhere is that apparent :(

Can someone from the Docker for Windows team clarify?

Kesmy commented 6 years ago

@christiansparre This is definitely far from the only place where both

  1. The documentation is ambiguous and
  2. The documentation is outright incorrect or invalid for at least one platform
ebriney commented 6 years ago

It's a Windows daemon limitation and needs to be fix there but we will add a workaround waiting MS to fix it upstream. Note that the official new name is host.docker.internal and docker.for.win.localhostis deprecated.

vitalii-ivanchenko commented 6 years ago

Guys, what is analog of "host.docker.internal" for Linux?

cybertk commented 6 years ago

Is there any update? Confirmed "host.docker.internal" does work on Win10 1709 build 16299.431

austinbachman commented 6 years ago

I'm running Docker on Windows with linux containers. host.docker.internal resolves with the default DNS configuration, however, in the case that I configure DNS in my docker-compose as such:

dns:
      - 10.xx.xx.xx

host.docker.internal does not resolve. Is there any way to configure a custom DNS like this but also still have host.docker.internal resolve within containers?

As a workaround, I disabled the custom DNS, used nslookup host.docker.internal within the container to find the IP, then replaced host.docker.internal within my app with that IP, and re-enabled the custom DNS, which is clearly not a portable solution.

ebriney commented 6 years ago

Fixed in 18.05 edge and 18.06 stable so I close it. @austinbachman can you create a new issue describing your use case? thanks. @vitalii-ivanchenko, good point, you should create an issue in https://github.com/moby/moby/issues so we can harmonize with desktop, all the more so in WCOW we need to do tricky things to inject host.docker.internal in containers.

shilpa88 commented 6 years ago

"host.docker.internal" does not work for windows 10

Cloudmersive commented 5 years ago

So this is broken?

docker-robott commented 4 years ago

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked

StefanScherer commented 3 years ago

Just a heads up, we finally removed experimental DNS names docker.for.win.localhost and others in Docker Desktop for Windows 3.2.0, you have to use host.docker.internal instead. See also #10619