Local DNS or Public DNS, why not both? (/etc/docker/daemon.json)

Issue description

When /etc/docker/daemon.json is configured as the following:

{
	"dns": ["192.168.1.33", "192.168.1.1", "8.8.8.8"],
        "dns-opts":["use-vc"],
        "dns-search": ["home.lan"]
}

Works: gitlab.home.lan, jenkins.home.lan in web browser
Works: sudo docker exec <container.id.of.jenkins> ping 192.168.1.33
Works: sudo docker exec <container.id.of.jenkins> ping gitlab.home.lan
Works: sudo docker exec <container.id.of.jenkins> ping 8.8.8.8
Does NOT work: sudo docker exec <container.id.of.jenkins> ping google.com

ping:google.com: Name or service not known

When /etc/docker/daemon.json is configured as the following:

{
	"dns": ["192.168.1.33", "192.168.1.1", "8.8.8.8"],
        "dns-search": ["home.lan"]
}

Works: gitlab.home.lan, jenkins.home.lan in web browser
Works: sudo docker exec <container.id.of.jenkins> ping 192.168.1.33
Does NOT work: sudo docker exec <container.id.of.jenkins> ping gitlab.home.lan

ping: gitlab.home.lan: Name or service not known

Works: sudo docker exec <container.id.of.jenkins> ping 8.8.8.8
Works: sudo docker exec <container.id.of.jenkins> ping google.com

Question

How should /etc/docker/daemon.json be configured to get both Local DNS and Public DNS working at the same time?

Setup

Docker container

On a single machine (192.168.1.33), there are a number of containers running

  • Bind (sameersbn/bind:latest)
  • Nginx reverse proxy (jwilder/nginx-proxy)
  • Gitlab (gitlab/gitlab-ce:latest)
  • Jenkins (jenkins/jenkins:lts)

Configuration:

  • containers are configured using version 2 of docker-compose (see below)
  • port 53 of Bind is mapped as udp and tcp
  • a master zone “home.lan” had been defined in Bind
  • Bind binds gitlab.home.lan, jenkins.home.lan, bind.home.lan to 192.168.1.33
  • nginx makes uses of environment variable VIRTUAL_HOST to route to the correct port
  • a network named “reverse-proxy” has been configured and all containers are using it.
  • 192.168.1.1 is a router, using 192.168.1.33 for the DNS
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:17:20 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:15:30 2018
  OS/Arch:      linux/amd64
  Experimental: false

Bind docker-compose-yml

version: "2"
services:
  Bind:
    image: sameersbn/bind:latest
    volumes:
      - /media/HDD/bind.home.lan:/data 
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "10000:10000/tcp"
    environment:
      - VIRTUAL_HOST=bind.home.lan
      - VIRTUAL_PORT=10000
    hostname: bind.home.lan
    networks:
      - reverse-proxy

networks:
  reverse-proxy:
    external:
      name: reverse-proxy

Nginx docker-compose.yml

version: "2"
services:
  nginx:
    image: jwilder/nginx-proxy
    volumes:
      - /media/HDD/nginx.home.lan/my_proxy.conf:/etc/nginx/conf.d/my_proxy.conf:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    ports:
      - "80:80"
      - "443:443"
    environment:
      - VIRTUAL_HOST=nginx.home.lan
      - VIRTUAL_PORT=80
    hostname: nginx.home.lan
    networks: 
      - reverse-proxy

networks:
  reverse-proxy:
    external:
      name: reverse-proxy

Gitlab docker-compose.yml

version: "2"
services:
  Gitlab:
    image: gitlab/gitlab-ce:latest
    volumes:
      - /media/HDD/gitlab.home.lan/config:/etc/gitlab
      - /media/HDD/gitlab.home.lan/logs:/var/log/gitlab
      - /media/HDD/gitlab.home.lan/data:/var/opt/gitlab
    ports:
      - "8085:80"
      - "10022:22"
      - "10443:443"
    environment:
      - VIRTUAL_HOST=gitlab.home.lan
      - VIRTUAL_PORT=80
    hostname: gitlab.home.lan
    networks:
      - reverse-proxy

networks:
  reverse-proxy:
    external:
      name: reverse-proxy

Jenkins docker-compose.yml

version: '2'
services:
  Jenkins:
    image: jenkins/jenkins:lts
    volumes:
      - /media/HDD/jenkins.home.lan:/var/jenkins_home
    ports:
      - "8088:8080"
      - "50000:50000"
    environment:
      - VIRTUAL_HOST=jenkins.home.lan
      - VIRTUAL_PORT=8080
    hostname: jenkins.home.lan
    networks:
      - reverse-proxy

networks:
  reverse-proxy:
    external:
      name: reverse-proxy

Host /etc/resolv.conf

nameserver 192.168.1.33
nameserver 192.168.1.1
nameserver 8.8.8.8
search home.lan

Containers /etc/resolv.conf

search home.lan
nameserver 127.0.0.11
options use-vc ndots:0
1 Like