Embedded DNS not working

Just started working with Docker, but was under the impression that finding containers by name was working? I created 2 simple containers that just ping themselves infinitely. I then connect to one and try to ping itself and the other container by name, but only pinging by container id works.

Consider:

C:\docker --version
Docker version 17.06.2-ce, build cec0b72
C:\docker create --name aaa --network-alias aaa microsoft/nanoserver ping -t localhost
C:\docker create --name bbb --network-alias bbb microsoft/nanoserver ping -t localhost
C:\docker start aaa bbb
C:\docker ps
CONTAINER ID  IMAGE                 COMMAND              NAMES
9c9a6f6735dc  microsoft/nanoserver  "ping -t localhost"  bbb
1a32e94b9090  microsoft/nanoserver  "ping -t localhost"  aaa

Connect to ‘aaa’:

C:\docker exec -it aaa cmd
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\>

Embedded DNS does not resolve via container name or network alias:

C:\>ping aaa
Ping request could not find host aaa. Please check the name and try again.

C:\>ping bbb
Ping request could not find host bbb. Please check the name and try again.

Only via container id:

C:\>ping 1a32e94b9090

Pinging 1a32e94b9090 [fe80::1108:7bea:858f:69bc%4] with 32 bytes of data:
Reply from fe80::1108:7bea:858f:69bc%4: time<1ms
Reply from fe80::1108:7bea:858f:69bc%4: time<1ms
Reply from fe80::1108:7bea:858f:69bc%4: time<1ms
Reply from fe80::1108:7bea:858f:69bc%4: time<1ms

Ping statistics for fe80::1108:7bea:858f:69bc%4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\>ping 9c9a6f6735dc

Pinging 9c9a6f6735dc [fe80::c91b:1dbe:8f28:b5ae%4] with 32 bytes of data:
Reply from fe80::c91b:1dbe:8f28:b5ae%4: time<1ms
Reply from fe80::c91b:1dbe:8f28:b5ae%4: time<1ms
Reply from fe80::c91b:1dbe:8f28:b5ae%4: time<1ms
Reply from fe80::c91b:1dbe:8f28:b5ae%4: time<1ms

Ping statistics for fe80::c91b:1dbe:8f28:b5ae%4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\>

I tried your sample and everything is working for me with latest version from Edge channel. My colleague however, is having some issues as you are. We encountered this first with docker-compose and services not finding each other by name. First I was thinking that it’s some VPN blocking issue but we tried shutting them down. Any ideas?

I have tried docker-compose and though docker ps shows Names listed, it seems name is not resolved, I have tried sample you have provided by you and the same problem occurred even with that, so somehow Names are not getting resolved because of which I am not able to establish connection with given name. Any ideas?

Just wondering if you ever found a solution for this lack of service-name host resolution using docker-compose on Windows? I’m seeing the same thing where host lookups that work fine using docker-compose on Linux, fail when using docker-compose on Windows. For reference, I’m using Windows 10 1703 with Docker 17.09.0-ce and docker-compose 1.16.1.

Sorry, yes, should have replied… It is the Windows firewall.

From what I understand, the host machine gets a virtual nic on the container network. Well, it technically can’t implicitly trust everything on that network, so it runs a firewall on the nic. The problem is that the docker dns runs on the host machine and the containers have the host machine ip in as a dns server. So… they try to connect to the host machine to resolve the other containers by name and they get blocked.

So, you need to disable the firewall on that nic… We just disabled the firewall, but the right answer would be to allow dns requests through…

1 Like