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

<p>When I do:</p>

<p><code>docker pull service.namespace.svc.cluster.local:5000/test:latest</code></p>

<p>I get: <code>dial tcp: lookup service.namespace.svc.cluster.local: no such host</code></p>

<p>but this works:</p>

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

<p>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:</p>

<p><a href="https://github.com/moby/moby/issues/23910" rel="nofollow noreferrer">https://github.com/moby/moby/issues/23910</a></p>

<p>Example config:</p>

<pre><code>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"]
}
</code></pre>

<p>See Also:
<a href="https://forums.docker.com/t/docker-pull-not-using-correct-dns-server-when-private-registry-on-vpn/11117/29" rel="nofollow noreferrer">https://forums.docker.com/t/docker-pull-not-using-correct-dns-server-when-private-registry-on-vpn/11117/29</a></p>
