docker / for-win

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

Cannot resolve host name in Docker Desktop Windows #3810

Closed stefangrossmann closed 2 years ago

stefangrossmann commented 5 years ago

Expected behavior

Assuming, my machine is named workstation-mine.company.network, with IP 10.11.12.13

When calling docker run busybox ping workstation-mine.company.network I would expect that my workstation is reachable from within a docker container.

Actual behavior

The result of the ping is:

ping: bad address 'workstation-mine.company.network'

Information

When I pass the IP of the company-dns it is working:

docker run --dns COMPANY_DNS_IP busybox ping workstation-mine.company.network

PING workstation-mine.company.network (172.25.35.141): 56 data bytes
64 bytes from 172.25.35.141: seq=0 ttl=37 time=1.654 ms
64 bytes from 172.25.35.141: seq=1 ttl=37 time=0.937 ms
64 bytes from 172.25.35.141: seq=2 ttl=37 time=1.333 ms
64 bytes from 172.25.35.141: seq=3 ttl=37 time=1.657 ms

It seems to be not possible to lookup the IP of the own host:

docker run busybox nslookup workstation-mine.company.network
Server:         192.168.65.1
Address:        192.168.65.1:53

** server can't find workstation-mine.company.network: NXDOMAIN

*** Can't find workstation-mine.company.network: No answer

With external hosts and other machines inside our network everything works fine:

docker run busybox ping other-workstation-mine.company.network
PING other-workstation-mine.company.network (10.11.12.14): 56 data bytes
64 bytes from 172.25.35.161: seq=0 ttl=37 time=3.755 ms
64 bytes from 172.25.35.161: seq=1 ttl=37 time=1.752 ms
64 bytes from 172.25.35.161: seq=2 ttl=37 time=1.721 ms
64 bytes from 172.25.35.161: seq=3 ttl=37 time=1.854 ms
64 bytes from 172.25.35.161: seq=4 ttl=37 time=3.148 ms
64 bytes from 172.25.35.161: seq=5 ttl=37 time=1.561 ms
64 bytes from 172.25.35.161: seq=6 ttl=37 time=1.560 ms

The behaviour is the same with if I use 'automatic' DNS-Discovery or if I use a fixed DNS-Server at my docker-settings.

See as well a stackoverflow post from another user which seems to have the same problem: https://stackoverflow.com/questions/55360231/how-to-make-docker-desktop-windows-resolve-the-host-name

docker-robott commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

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

stefangrossmann commented 5 years ago

Still valid. But no coment, nothing :-( /remove-lifecycle stale

michaeldahlke commented 5 years ago

I upgraded to 2.1.0.0 today and am now experiencing the same issue. Manually setting DNS Server fixed to internal company DNS does not solve the issue. I've tried factory resetting and rebooting with no effect. Only way to resolve internal addresses is by passing --dns argument with docker run. So far I have found no workaround at all for Kubernetes.

jordanbrowneb commented 5 years ago

Getting the same behavior as @michaeldahlke , had to revert back to 2.0.0.3

mrbrazzi commented 5 years ago

Same behavior as @stefangrossmann. I upgraded to 2.1.0.0 today.

Expected behavior

Get valid ping or nslookup response using busybox docker image

Actual behavior

image

The ip address that appears as nameserver in /etc/resolv.conf is assigned automatic by Docker according to Network settings. image

If I set the DNS configuration fixed in Docker, the result is the same. See the following images:

volkflo commented 5 years ago

Same problem as @michaeldahlke too. Setting the dns fixed does not affect anything.

tze commented 5 years ago

Same problem here. Name resolution of containers inside the same docker-network is not working either. Edit: My bad containers can see each other, however name resolution of the host name is not working. Not in 2.1.0.1 either.

ericojbf commented 5 years ago

Same problem. I had to downgrade to 2.0.0.3. It is working properly.

volkflo commented 5 years ago

If using docker-compose than extra_hosts is a workaround: https://docs.docker.com/compose/compose-file/#extra_hosts

mrbrazzi commented 5 years ago

Same behavior as @stefangrossmann. I upgraded to 2.1.0.0 today.

  • [x] I have tried with the latest version of my channel (Stable or Edge)
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: E37D09A7-F695-4F6A-9380-A544CF140879/20190804194525
  • Windows Version: Windows 10 Pro 1809 build 17763.379
  • Docker Desktop Version: 2.1.0.0 image

Expected behavior

Get valid ping or nslookup response using busybox docker image

Actual behavior

image

The ip address that appears as nameserver in /etc/resolv.conf is assigned automatic by Docker according to Network settings. image

If I set the DNS configuration fixed in Docker, the result is the same. See the following images:

  • This my local ip configuration: image
  • Apply fixed DNS configuration and restart Docker image
  • Using ping and nslookup in busybox. Check that busybox not have the same DNS ip address that is setted in DNS configuration in Docker image but, if I set --dns option with docker run command, the result is the same, image also, if I change the daemon configuration in Docker, same result, see the following images: image image

I upgrade to version 2.1.01 (37199). The problem persist.

jredp commented 5 years ago

Confirming that this isn't resolved in 2.1.0.1. I have upgraded to both 2.1.0.0 and 2.1.0.1 and the issue is in both versions. I resolved it by downgrading to previous version 2.0.0.3.

tze commented 5 years ago

@jredp Is it possible to downgrade without loosing the existing containers and images?

inech commented 5 years ago

Same problem

jredp commented 5 years ago

@jredp Is it possible to downgrade without loosing the existing containers and images?

I'm sorry @tze I am not sure on that one. It depends on how they do the uninstall and if they fully clean out those during the uninstaller process. I had to run the uninstaller and then install to "downgrade". In other words, not an actual rollback. I pull a docker image when I run so I don't need to worry about existing images.

Another version came out today. I don't see a comment from anyone that they have reviewed this bug. I'm not sure how to tell. Though, to be fair, it looks like they have 678 issues right now in Docker for Win.

gfleague commented 5 years ago

This also applies to Docker-ee on Windows Server 2019.

It seems the /etc/hosts file is not generated or mounted into the docker container, whereas /etc/resolv.conf seems right.

Vinss85 commented 5 years ago

I'm using Docker 2.1.0.2 for windows, the problem is still there

mrbrazzi commented 5 years ago

Hi, I found a solution... I'm using Docker 2.1.0.2 and after execute a Reset to factory defaults everything's work fine... I run a container with busybox image, execute ping to google.com.cu and receive a valid ICMP response... also I compile a project that require download libraries with pip and it worked fine!!!

I hope this radical solution can help you...

Happy hacking!!!

sebfere commented 5 years ago

Thanks @mrbrazzi Reset to factory defaults with Docker 2.1.x also worked for me :)

gfleague commented 5 years ago

How can I reset to factory defaults with Docker-ee on Windows Server 2019 ?

KiameV commented 5 years ago

Reset to factory defaults is not working with Docker Desktop for Windows. I have version 2.1.0.3.

Problem: I have an artifactory go repo on a company VPN. When building a docker image I need to be able to pull libraries from artifactory; thus I need to set the DNS Server to the VPN's dns. This has worked in previous version of Docker Desktop but no longer. I get the following error whether the DNS Server is set to Automatic or Fixed dial tcp: lookup artifactory.dev.companyname.net on 192.168.65.1:53: no such host

Expected: When I set DNS Server to Fixed, that DNS server is used instead of 8.8.8.8.

The last version where Fixed DNS Server worked is 2.0.0.3 2019-02-15

dpmott commented 4 years ago

I've had the same experience with Docker Desktop for Windows versions 2.1.0.1 and 2.1.0.3.

Reset to factory defaults (as described here: https://docs.docker.com/docker-for-windows/#reset) also did not help.

I tried configuring the docker daemon dns setting to be my domain DNS server, which knows how to resolve my local host's fully qualified DNS name. As others have experienced, this doesn't seem to help. In fact, resolution of the magical DNS name host.docker.internal fails if I configure the docker daemon dns in this fashion.

The solution of adding an extra_hosts entry cannot be applied to all of my use-cases (in some cases, the compose file is not mine to manipulate).

I also don't have the option of using the magical host.docker.internal DNS name, because I need a DNS name that resolves both inside the docker container, and in locally running scripts. (I'm using a JWT whose issuer is set to my local machine's FQDNS, and this JWT is used both locally and in the docker container.)

I've resorted to creating a script that essentially looks up the container which needs to resolve my local host by name, and invokes: docker exec <container> /bin/sh -c "echo '<ip_address>\t<local_hostname>' >> /etc/hosts"

Some irony here: You can locally lookup your local host's IP address by a DNS lookup of host.docker.internal, because Docker for Windows maintains that DNS name in your local C:\Windows\System32\drivers\etc\hosts file. So, that makes it kinda easy to get your current IP address for the docker exec command above.

cknolla commented 4 years ago

Same problem and fix as everyone else. Had 2.1.0.2, no network or DNS configuration would resolve. Reverted to 2.0.0.3 and default network settings with automatic DNS works fine.

xlf12 commented 4 years ago

No news when trying 2.1.0.3 ... the issue still exists ...

KiameV commented 4 years ago

It appears that 'fixed dns server' finally works again with version 2.1.0.4

pitersk commented 4 years ago

I am not sure if this is the same issue, but docker DNS does not resolve hostname until you use FQDN. Example: docker pull registry:8500/repo/image:tag
gives me Error response from daemon: Get https://registry:8500/v2/: dial tcp: lookup registry on 192.168.65.1:53: no such host but docker pull registry.company.domain:8500/repo/image:tag works

same with docker run busybox ping registry - not working docker run busybox ping registry.company.domain - working docker desktop version: 2.1.0.4

all this used to work before

michaeldahlke commented 4 years ago

Issue is still not resolved for me when pinging local computer using internal company name FQDN. Other internal network computers are still reachable. Using Docker Desktop 2.1.0.4.

michaeldahlke commented 4 years ago

I wrote a workaround PowerShell cmdlet to fix running containers /etc/hosts based on the solution @dpmott posted. This is particularly handy for Kubernetes as there is no other workaround.

https://gist.github.com/michaeldahlke/8fd716b4a2e4cf4b585e1f92fe31dabd

KylePreuss commented 4 years ago

Fixed DNS Server setting is still not observed in v2.1.0.5. Cannot push/pull from local registries using host name.

Related: #4425

riverar commented 4 years ago

Seeing similar issues with resolving container hostnames on the same network (or via docker-compose links) using the nat driver. (cc: @mat007)

Client: Docker Engine - Enterprise
 Version:           19.03.5
 Git commit:        2ee0c57608
 Built:             11/13/2019 08:00:16
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Enterprise
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.8
  Git commit:       c92ab06ed9
  Built:            09/03/2019 16:35:47
  OS/Arch:          windows/amd64
  Experimental:     true
doggy8088 commented 4 years ago

I'm also suffered from this issue due to unknown issue. It works before.

C:\>docker run -it --rm --network=nat --isolation=process mcr.microsoft.com/windows/servercore:1909 nslookup go.microsoft.com

Server:  UnKnown
Address:  172.29.16.1

*** UnKnown can't find go.microsoft.com: Server failed

Docker Version

C:\>docker version

Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:31 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.24)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:28:48 2019
  OS/Arch:          windows/amd64
  Experimental:     false

I tried to re-install & downgrade to Docker Desktop 2.0.0.3, it still not working.

image

I also tried to removed all the network interface, not working either.

Get-HnsNetwork | Remove-HnsNetwork
&"C:\Program Files\Docker\Docker\Docker for Windows.exe"

I also tried using --dns or configure daemon.json's dns property. Not working.

docker run -it --rm --network=nat --dns="8.8.8.8" --isolation=process mcr.microsoft.com/windows/servercore:1909 nslookup go.microsoft.com

Is there any other workaround available right now?

riverar commented 4 years ago

@doggy8088 On Windows, docker ships with the nat network. This is not a "user created" network therefore containers do not automatically get added to the built-in DNS server and will not resolve automatically. If you want that behavior, create your own, similar network using the nat driver, e.g. docker network create --driver nat --ipam-driver windows my-network-name then attach your containers to that.

Docker may change this behavior (in our favor) very soon. For more information, see moby/moby#40357

doggy8088 commented 4 years ago

@riverar I tried this:

docker network create --driver nat --ipam-driver windows mynat

docker run -it --rm --network=mynat --isolation=process mcr.microsoft.com/windows/servercore:1909 nslookup go.microsoft.com

Server:  UnKnown
Address:  172.26.208.1

*** UnKnown can't find go.microsoft.com: Server failed

It's not working.

michaeldahlke commented 4 years ago

Issue still not resolved in Docker Desktop 2.2.0.0

doggy8088 commented 4 years ago

I'm using a workaround by executing Set-DnsClientServerAddress comdlet inside container.

Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses 8.8.8.8
kmz850 commented 4 years ago

Still not working in Docker Desktop 2.2.0.3 for me.

mrbrazzi commented 4 years ago

Still not working in Docker Desktop 2.2.0.3 for me.

Did you do a factory reset? I was in same situation some versions ago (<2.1) and after upgrade to major version 2.1 and execute a factory reset it works fine. Actually I'm using Docker Desktop 2.2.* without any problem...

volkflo commented 4 years ago

@mrbrazzi I did a factory reset this morning, but this did not help as well.

clawrenceks commented 4 years ago

Factory reset definitely does not fix this issue for me. To workaround the issue I just set the dns servers to use in the daemon configuration using the syntax below in the json config.

"dns": ["8.8.8.8"]

AlexPaskhin commented 4 years ago

Just Add i.e. suffix ".home" in the compose file for the container Like that:

 rabbitmq:
    networks:
        eshop_net:
          aliases:
            - rabbitmq.home
    container_name: rabbitmq
    hostname: rabbitmq
    image: rabbitmq:3-management-alpine
    ports:
      - "15672:15672"
      - "5672:5672"

Works fine For Docker EE on 2019

Jan1torEarl commented 4 years ago

Same issue here! Been having a connection problem in our dev environments for a few months now and finally found the time to dig into it. Sure enough, after much troubleshooting, realized that Docker suddenly stopped resolving local network names, whereas our exact same containers worked perfectly fine in previous versions.

AlexPaskhin commented 4 years ago

Here is docker-compose fragment which is worked fine. The core issue is dns service, not Docker , but linux images that used by 'net core' and so on. I have add alpine to "endless" run, which is perfect 5mb dns service for my network. In case it is easy to check what's up inside your container network, just attach to container.

version: '3.7'

services:

  rabbitmq:
    networks:
      eshop_net:
        aliases:
          - rabbitmq.home      #important alias
    container_name: rabbitmq
    hostname: rabbitmq
    image: rabbitmq:3-management-alpine
    ports:
      - "15672:15672"
      - "5672:5672"

  alpinebox:
    networks:
      eshop_net:
        aliases:
          - alpinebox.home    #important alias
    container_name: alpinebox
    hostname: alpinebox
    image: alpine
    entrypoint: /bin/sh
    stdin_open: true
    tty: true

networks:
    eshop_net:
Jan1torEarl commented 4 years ago

FWIW for me this is only a problem for hosts without a dot (.) in the name. For example mylanwebserver.com resolves fine but MSSQLSERVER1 or SOMEONESWINDOWSPC doesn't.

AlexPaskhin commented 4 years ago

I am using allias with suffix '.home' in this case it works fine for names without it. See yaml example.

pablomfc commented 4 years ago

With:

{ "bridge" : "none" } At C:\ProgramData\Docker\config\daemon.json

I was able to pull from private container registry.

TheBlueSky commented 4 years ago

I'm not sure everyone who is following this issue has the same problem, but here is mine and what solved it for me:

I'm building a Docker Image that requires downloading a file from the internet. The step that downloads the file fails because the command was unable to resolve the hostname.

When I tried to ping any hostname; e.g., microsoft.com, I get Ping request could not find host microsoft.com. Please check the name and try again.

I followed a few of the suggestion in this issue, like resetting Docker to factory setting and using a custom network, but none worked with me.

What worked with me, however, was the suggestion here; I added the following to Docker Engine settings:

  "dns": [
    "1.1.1.1"
  ]

Thanks, @clawrenceks.

ordinaryorange commented 4 years ago

Running 2.3.02 on windows 1903 in experimental mode (mixed linux and windows containers) here and also having this issue. Any linux container that does a hostname -i during startup will fail, as the DNS will not resolve. Tried a number of ideas to work around the problem, but came up empty. Not having a working DNS is making dev on a Windows machine hard. This issue is now > 12 months old is it even on the todo ?

cowlinator commented 4 years ago

This is still an issue for 2.3.03 (45519) and Windows 1809

cowlinator commented 4 years ago

@mikeparker @rn @akshaybabloo @gtardif @akimd @macdja38 @ebriney @duglin @MagnusS @dave-tucker

Is this issue on Docker's radar at all?

macdja38 commented 4 years ago

@mikeparker @rn @akshaybabloo @gtardif @akimd @macdja38 @ebriney @duglin @MagnusS @dave-tucker

Is this issue on Docker's radar at all?

I’m just a random person… I have no connection to docker and no idea if this is on their radar.

Edit: Sorry if the quote pinged anyone, I was on mobile and didn't even thing it might mention everyone again.

cowlinator commented 4 years ago

Sorry, I was going off the list of people who had committed to this docker/for-win repo.