Hello I am unable to get DNS working correctly when using docker-compose 1.6.2 and docker engine 1.10.3
I have the following in my docker-compose.yml
version: '2'
services:
cassandra.dev:
dns:
- <internal DNS server>
- 8.8.8.8
dns_search: domain.local
mem_limit: 1g
image: cassandra
container_name: cassandra
environment:
- DOCKER_HOST
- SERVICE_CHECK_SCRIPT='nodetool info'
- SERVICE_CHECK_TTL=20s
ports:
- 9100:9160
- 9200:9042
I bash into the container and look at the /etc/resolv.conf file.
root@9d11f3630a09:/# cat /etc/resolv.conf
search domain.local
nameserver 127.0.0.11
options ndots:0
Awesome, its using the embedded DNS server as designed
root@9d11f3630a09:/# ping server.domain.local
PING server.domain.local (<ip address>): 48 data bytes
It works as expected…
Try and ping something on the internet
root@9d11f3630a09:/# ping www.google.com
ping: unknown host
Hmm… why is it doing this?
Ran inspect on the container
docker inspect -f '{{ .HostConfig.Dns}}' cassandra
[<internal DNS server> 8.8.8.8]
Looks good.
I switched the dns compose file around to:
dns:
- 8.8.8.8
- <internal DNS server>
I brought down the container and brought it back up.
I pinged www.google.com (worked!)
pinged server.domain.local response was unknown host.
So I decided to manipulate the /etc/resolv.conf file manually on the container just to make sure it behaved the same.
I modified it to:
search domain.local
nameserver <internal DNS server>
nameserver 8.8.8.8
After I did that. I pinged www.google.com and got an appropriate response and then pinged server.domin.local and it also worked as expected.
But of course I tried to ping itself (the container name) and it failed since it wasn’t looking at the embedded DNS server.
It looks like the embedded DNS server doesn’t cycle through DNS names on name resolution failures or recursion failures.
recursion is disabled on the internal DNS server and not able to enable it.
What do I need to do to get around this issue?