Curling docker.local after running nginx container hangs for ~5 seconds

Expected behavior

After running docker run -d -p 80:80 nginx, curl docker.local should respond in a reasonable amount of time.

Actual behavior

curl docker.local consistently hangs for around 5 seconds. Some other potentially relevant things:

  • ping docker.local: perfoms normally
  • ping 192.168.64.2: performs normally
  • curl 192.168.64.2: performs normally (name resolution problems?)
  • nc -z docker.local 80: hangs for 5 seconds then succeeds
  • nc -z 192.168.64.2 80: performs normally

Information

  • pinata diagnose -u:
OS X: version 10.11.4 (build: 15E65)
Docker.app: version v1.11.0-beta8.2
Running diagnostic tests:
[OK]      docker-cli
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160428-141528.tar.gz
Most specific failure is: No error was detected
Your unique id is: 0E586D17-BE5B-4D6E-ABC4-54F06F25DFE7
Please quote this in all correspondence.

Steps to reproduce the behavior

  1. Install Docker for Mac beta.
  2. Run docker run -d -p 80:80 nginx
  3. Run curl docker.local

Digging into this more with tcpdump, it does indeed appear that it has something to do with dns cacheing—when the request is made with curl, there’s 5 seconds worth of mDNS traffic before the HTTP request goes out, whereas in the browser, this does not happen, presumably due to browser-internal DNS cacheing. Now that I think about it, I remember the browser hanging for 5 seconds the very first time I used it to make a request to docker.local. Also plausibly related is this cryptic blog post. I’m going to dig into it more and see if I can figure out exactly what’s wrong with mDNS.

Here is a tcpdump of what happens during the curl, in case it’s interesting:

16:15:35.536113 IP 192.168.64.1.mdns > 224.0.0.251.mdns: 0 [2q] A (QU)? docker.local. AAAA (QU)? docker.local. (36)
16:15:35.536522 IP 192.168.64.2.mdns > 192.168.64.1.mdns: 0*- [0q] 1/0/0 A 192.168.64.2 (40)
16:15:36.614929 IP 192.168.64.1.mdns > 224.0.0.251.mdns: 0 [1a] [2q] A (QM)? docker.local. AAAA (QM)? docker.local. (52)
16:15:36.615467 IP 192.168.64.2.mdns > 192.168.64.1.mdns: 0*- [0q] 1/0/0 A 192.168.64.2 (40)
16:15:38.988901 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [S], seq 577689276, win 65535, options [mss 1460,nop,wscale 5,nop,nop,TS val 1139119169 ecr 0,sackOK,eol], length 0
16:15:38.989408 IP 192.168.64.2.http > 192.168.64.1.60646: Flags [S.], seq 66653052, ack 577689277, win 28960, options [mss 1460,sackOK,TS val 1018688 ecr 1139119169,nop,wscale 7], length 0
16:15:38.989447 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [.], ack 1, win 4117, options [nop,nop,TS val 1139119169 ecr 1018688], length 0
16:15:38.989515 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [P.], seq 1:77, ack 1, win 4117, options [nop,nop,TS val 1139119169 ecr 1018688], length 76: HTTP: GET / HTTP/1.1
16:15:38.989774 IP 192.168.64.2.http > 192.168.64.1.60646: Flags [.], ack 77, win 227, options [nop,nop,TS val 1018688 ecr 1139119169], length 0
16:15:38.989923 IP 192.168.64.2.http > 192.168.64.1.60646: Flags [P.], seq 1:239, ack 77, win 227, options [nop,nop,TS val 1018688 ecr 1139119169], length 238: HTTP: HTTP/1.1 200 OK
16:15:38.989949 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [.], ack 239, win 4110, options [nop,nop,TS val 1139119170 ecr 1018688], length 0
16:15:38.990010 IP 192.168.64.2.http > 192.168.64.1.60646: Flags [P.], seq 239:851, ack 77, win 227, options [nop,nop,TS val 1018688 ecr 1139119169], length 612: HTTP
16:15:38.990029 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [.], ack 851, win 4091, options [nop,nop,TS val 1139119170 ecr 1018688], length 0
16:15:38.990163 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [F.], seq 77, ack 851, win 4096, options [nop,nop,TS val 1139119170 ecr 1018688], length 0
16:15:38.990460 IP 192.168.64.2.http > 192.168.64.1.60646: Flags [F.], seq 851, ack 78, win 227, options [nop,nop,TS val 1018688 ecr 1139119170], length 0
16:15:38.990627 IP 192.168.64.1.60646 > 192.168.64.2.http: Flags [.], ack 852, win 4096, options [nop,nop,TS val 1139119170 ecr 1018688], length 0

Whoops, apparently this is a dup of Slow IP resolution of docker container. Also docker.local is not a thing anymore in beta9 anyway :slight_smile: