Understanding the 'docker.for.mac.localhost' behavior

Not being a docker developer I can just speculate: 192.168.65.1 is an address magically mapped to 127.0.0.1 in the host network namespace, while 172.17.0.1 is the gateway address in the bridge network. The latter is used by default for forwarding all outbound traffic to other computers until you start to reconfigure your container’s routing table. So actually they belong to two different networks not reachable from each other.

In the meanwhile the DNS server seems to be fixed. With 17.09.1-ce-mac42, I get:

/ # drill docker.for.mac.localhost
;; QUESTION SECTION:
;; docker.for.mac.localhost.	IN	A

;; ANSWER SECTION:
docker.for.mac.localhost.	0	IN	A	192.168.65.1

;; SERVER: 192.168.65.1