Docker ignoring local dns settings

11/6/2018

I launched a jenkins-k8s-slave which should pull from a local registry. Why does docker ignore the local DNS settings (/etc/hosts and /etc/resolv.conf) managed by kubernetes?

When I do:

docker pull service.namespace.svc.cluster.local:5000/test:latest

I get: dial tcp: lookup service.namespace.svc.cluster.local: no such host

but this works:

curl https://service.namespace.svc.cluster.local:5000/v2/_catalog -k {"repositories":[...]}

-- Techradar
dns
docker
jenkins
kubernetes
resolve

1 Answer

11/6/2018

You will need to configure docker to use your dns , whatever that may be , in this case , it seems that you need to tell docker to use the kubernetes dns:

https://github.com/moby/moby/issues/23910

Example config:

cat /etc/docker/daemon.json

{
    "hosts": [ "unix:///var/run/docker.sock","tcp://0.0.0.0:2376"],
    "live-restore": true,
    "tls": true,
    "tlscacert": "/etc/docker/ssl/ca.pem",
    "tlscert": "/etc/docker/ssl/cert.pem",
    "tlskey": "/etc/docker/ssl/key.pem",
    "tlsverify": true,
    "dns":["172.21.1.100","172.16.1.100"]
}

See Also: https://forums.docker.com/t/docker-pull-not-using-correct-dns-server-when-private-registry-on-vpn/11117/29

-- Ijaz Ahmad Khan
Source: StackOverflow