我有一个基于jenkins / jenkins:lts-alpine的docker镜像。由于某些原因,它无法解析DNS名称,如下所示:
[root@inf-jenkins02-prd ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
716ceece2017 myjenkins/jenkins:latest "/sbin/tini -- /us..." 12 minutes ago Up 12 minutes 8080/tcp, 50000/tcp jenkins_main.1.heaupued6g8eygrgrk6c8hlvy
[root@inf-jenkins02-prd ~]# docker exec -ti 716ceece2017 nslookup www.google.com
nslookup: can't resolve '(null)': Name does not resolve
nslookup: can't resolve 'www.google.com': Try again
[root@inf-jenkins02-prd ~]#
但是,可以按预期运行以下内容:
[root@inf-jenkins02-prd ~]# docker run myjenkins/jenkins:latest nslookup google.com
nslookup: can't resolve '(null)': Name does not resolve
Name: google.com
Address 1: 216.58.204.142 par21s05-in-f142.1e100.net
以下是用于构建映像的Dockerfile:
FROM jenkins/jenkins:lts-alpine
ENV JAVA_OPTS="-Djenkins.install.runSetupWizard=false -Dhudson.DNSMultiCast.disabled=true -Dhudson.udp=-1"
USER jenkins
RUN ssh-keygen -q -t rsa -N '' -f /var/jenkins_home/.ssh/id_rsa
COPY security.groovy /usr/share/jenkins/ref/init.groovy.d/security.groovy
COPY xlocation.groovy /usr/share/jenkins/ref/init.groovy.d/xlocation.groovy
COPY znodes.groovy /usr/share/jenkins/ref/init.groovy.d/znodes.groovy
COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt
这是docker-compose文件:
version: "3.1"
services:
main:
container_name: jenkins-mine
image: myjenkins/jenkins
deploy:
placement:
constraints:
- node.role == manager
ports:
- 8080:8080
- 50000:50000
volumes:
- /home/jenkins:/var/jenkins_home/
- /var/run/docker.sock:/var/run/docker.sock
然后,我正在做:
docker stack deploy -c /.../docker-compose.yml jenkins
一切似乎都还可以:
[root@inf-jenkins02-prd ~]# docker service ls
ID NAME MODE REPLICAS IMAGE
71h4jrygqp7m jenkins_main replicated 1/1 myjenkins/jenkins
[root@inf-jenkins02-prd ~]# docker service ps 71h4jrygqp7m
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
heaupued6g8e jenkins_main.1 myjenkins/jenkins inf-jenkins02-prd Running Running 23 minutes ago
[root@inf-jenkins02-prd ~]#
但是google.com无法解决:
[root@inf-jenkins02-prd ~]# docker exec -ti 716ceece2017 nslookup www.google.conf
nslookup: can't resolve '(null)': Name does not resolve
nslookup: can't resolve 'www.google.conf': Try again
[root@inf-jenkins02-prd ~]# docker exec -ti 716ceece2017 cat /etc/resolv.conf
search ...
nameserver 127.0.0.11
options ndots:0
[root@inf-jenkins02-prd ~]#
对这里发生的事情有任何想法吗?预先非常感谢。
亲切的问候,
尼古拉斯
答案 0 :(得分:0)
如果您看到消息useMutation
,那是因为volatile
正在查找要将DNS查询发送到的服务器的名称。由于您没有提供,因此为nslookup: can't resolve '(null)': Name does not resolve
。这是nslookup
中的一个已知问题(请参见https://github.com/gliderlabs/docker-alpine/issues/476)。有关更多详细信息,另请参见this SO question。
要检查的一件事是您正在查找正确的域。
在这里,您查找的是null
,而不是nslookup
。 www.google.conf
不存在,因此您期望得到的输出。
www.google.com
要检查的另一件事是尝试使用其他DNS解析器进行www.google.conf
。
例如:
# docker exec -ti 716ceece2017 nslookup www.google.conf
nslookup: can't resolve '(null)': Name does not resolve
nslookup: can't resolve 'www.google.conf': Try again
然后您可以查看问题是互联网还是DNS服务器。