Docker忽略本地DNS设置

时间:2018-11-06 16:48:13

标签: docker jenkins dns kubernetes resolve

我启动了一个setup.template.name: "packets",它应该从本地注册表中提取。为什么docker会忽略kubernetes管理的本地DNS设置(jenkins-k8s-slave/etc/hosts)?

当我这样做时:

/etc/resolv.conf

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

但这可行:

dial tcp: lookup service.namespace.svc.cluster.local: no such host curl https://service.namespace.svc.cluster.local:5000/v2/_catalog -k

1 个答案:

答案 0 :(得分:1)

您将需要配置docker以使用您的dns,在这种情况下,似乎需要告诉docker使用kubernetes dns:

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

示例配置:

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"]
}

另请参阅: https://forums.docker.com/t/docker-pull-not-using-correct-dns-server-when-private-registry-on-vpn/11117/29