1

I have a docker image based on jenkins/jenkins:lts-alpine. For some reason, it is not able to resolve DNS names, as shown below:

[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 ~]#

However, running the following works as expected:

[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

Here is the Dockerfile use to build the image:

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

And this is the docker-compose file:

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

Then, I'm just doing:

docker stack deploy -c /.../docker-compose.yml jenkins

Everything seems to be okay:

[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 ~]#

but google.com can't resolve:

[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 ~]#

Any idea of what's happening here ? Many thanks in advance.

Kind regards,

Nicolas

1 Answers1

0

If you ever see the message nslookup: can't resolve '(null)': Name does not resolve, it's because nslookup is looking up the name of the server you're going to send the DNS query to. Since you didn't provide one, it's null. This is a known issue in nslookup (see https://github.com/gliderlabs/docker-alpine/issues/476). See also this SO question for more details..

One thing to check is that you're looking up the right domain. Here, you looked up www.google.conf, not www.google.com. www.google.conf does not exist, so the output you got is expected.

# 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

Another thing to check is to try nslookup with a different DNS resolver. For example:

docker exec -ti 716ceece2017 nslookup www.google.conf 8.8.8.8

Then you can see if the issue is the Internet, or the DNS server.

kimbo
  • 2,513
  • 1
  • 15
  • 24