Como posso configurar minha máquina local para usar um servidor DNS hospedado no docker junto com outras configurações de DNS para domínios específicos?

Como posso configurar minha máquina local para usar um servidor DNS hospedado no docker junto com outras configurações de DNS para domínios específicos?

Eu tenho o seguinte docker-compose.yml usado como solução local do aplicativo web php:

version: "3.1"

services:
  nginx:
    image: nginx:1.13
    volumes:
      - "./configuration/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "./configuration/etable-local.key:/etc/nginx/etable-local.key:ro"
      - "./configuration/etable-local.crt:/etc/nginx/etable-local.crt:ro"
      - "website:/var/www/html/website"
      - "api:/var/www/html/static"
    links:
      - "php708:website"
      - "php72:api"
    networks:
      frontend:
        ipv4_address: 172.20.0.5
    ports:
      - "80:80"
      - "443:443"

  php72:
    image: php:7.2-fpm-alpine
    volumes:
      - "api:/var/www/html/api"
    environment:
      ENVIRONMENT: local
    networks:
      - frontend
    dns:
      - 8.8.8.8
      - 9.9.9.9
  website:
    image: php:7.2-fpm-alpine
    volumes:
      - "api:/var/www/html/api"
    environment:
      ENVIRONMENT: local
    networks:
      - frontend
    dns:
      - 8.8.8.8
      - 9.9.9.9
volumes:

  website:
    driver: local
    driver_opts:
      type: "none"
      o: "bind"
      device: $WEBSITE_DIR

  api:
    driver: local
    driver_opts:
      type: "none"
      o: "bind"
      device: $API_DIR

networks:
  frontend:
    ipam:
      config:
        - subnet: 172.20.0.0/24

E no meu computador que executa o contêiner docker, tenho as seguintes entradas em/etc/hosts:

172.20.0.5 api.local
172.20.0.5 website.local

Mas também quero servir domínios curinga, portanto, estou pensando em enviar também um dnsmasq com as configurações apropriadas em meu docker-compose e abandonar completamente /etc/hosts(melhor capacidade de reutilização e configurações compartilhadas entre a equipe):

version: "3.1"

services:
  nginx:
    image: nginx:1.13
    volumes:
      - "./configuration/nginx.conf:/etc/nginx/nginx.conf:ro"
      - "./configuration/etable-local.key:/etc/nginx/etable-local.key:ro"
      - "./configuration/etable-local.crt:/etc/nginx/etable-local.crt:ro"
      - "website:/var/www/html/website"
      - "api:/var/www/html/static"
    links:
      - "php708:website"
      - "php72:api"
    networks:
      frontend:
        ipv4_address: 172.20.0.5
    ports:
      - "80:80"
      - "443:443"

  php72:
    image: php:7.2-fpm-alpine
    volumes:
      - "api:/var/www/html/api"
    environment:
      ENVIRONMENT: local
    networks:
      - frontend
    dns:
      - 8.8.8.8
      - 9.9.9.9

  website:
    image: php:7.2-fpm-alpine
    volumes:
      - "api:/var/www/html/api"
    environment:
      ENVIRONMENT: local
    networks:
      - frontend
    dns:
      - 8.8.8.8
      - 9.9.9.9

  dnsmasq:
     image: 'jpillora/dnsmasq'
     ports:
      - "53:53/udp" 
      - "5380:8080"
    volumes:
       -"/opt/dnsmasq.conf:/etc/dnsmasq.conf"
    environment:
        HTTP_USER: foo
        HTTP_PASS: bar
    networks:
      frontend:
        ipv4_address: 172.20.0.6
    dns:
      - 8.8.8.8
      - 9.9.9.9

volumes:

  website:
    driver: local
    driver_opts:
      type: "none"
      o: "bind"
      device: $WEBSITE_DIR

  api:
    driver: local
    driver_opts:
      type: "none"
      o: "bind"
      device: $API_DIR

networks:
  frontend:
    ipam:
      config:
        - subnet: 172.20.0.0/24

Mas como posso configurar minha máquina GNU/Linux local e Windows para resolver os domínios apropriados junto 172.20.0.6com qualquer outro domínio?

No meu linux mint 19.04, depois de executar o ifconfig, recebo as seguintes configurações:

br-144546484da6: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:ee:ad:b4:6b  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br-2c821d16ac40: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.24.0.1  netmask 255.255.0.0  broadcast 172.24.255.255
        ether 02:42:d1:29:8f:d0  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

br-936b043d07ec: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.20.0.1  netmask 255.255.255.0  broadcast 172.20.0.255
        inet6 fe80::42:31ff:fe3b:6a93  prefixlen 64  scopeid 0x20<link>
        ether 02:42:31:3b:6a:93  txqueuelen 0  (Ethernet)
        RX packets 21190  bytes 46944301 (46.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20152  bytes 3393362 (3.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:63:fa:1e:98  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.4  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::4819:e008:32b3:eb75  prefixlen 64  scopeid 0x20<link>
        ether 30:5a:3a:82:3c:2c  txqueuelen 1000  (Ethernet)
        RX packets 1020236  bytes 974038110 (974.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 708231  bytes 83763973 (83.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 35856  bytes 3871878 (3.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 35856  bytes 3871878 (3.8 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.1  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::800:27ff:fe00:3  prefixlen 64  scopeid 0x20<link>
        ether 0a:00:27:00:00:03  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1537  bytes 248272 (248.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth15937a1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::f828:5eff:fe17:5f3f  prefixlen 64  scopeid 0x20<link>
        ether fa:28:5e:17:5f:3f  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1299  bytes 200892 (200.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth4f39177: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::7807:8bff:fef4:90d6  prefixlen 64  scopeid 0x20<link>
        ether 7a:07:8b:f4:90:d6  txqueuelen 0  (Ethernet)
        RX packets 4022  bytes 2287668 (2.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4674  bytes 1238082 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethb2863e3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::986d:2aff:feae:5a83  prefixlen 64  scopeid 0x20<link>
        ether 9a:6d:2a:ae:5a:83  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1279  bytes 197402 (197.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethe23b637: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::d8cf:8dff:fe79:2de  prefixlen 64  scopeid 0x20<link>
        ether da:cf:8d:79:02:de  txqueuelen 0  (Ethernet)
        RX packets 10344  bytes 1065309 (1.0 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11282  bytes 1252992 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethea02dde: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::a8aa:72ff:fe3f:f7f6  prefixlen 64  scopeid 0x20<link>
        ether aa:aa:72:3f:f7:f6  txqueuelen 0  (Ethernet)
        RX packets 1792  bytes 43279416 (43.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2443  bytes 307732 (307.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethf1bdbae: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::6cd3:dfff:feec:1000  prefixlen 64  scopeid 0x20<link>
        ether 6e:d3:df:ec:10:00  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1272  bytes 196493 (196.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethf209ff2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::7c6c:11ff:fecc:25c7  prefixlen 64  scopeid 0x20<link>
        ether 7e:6c:11:cc:25:c7  txqueuelen 0  (Ethernet)
        RX packets 5594  bytes 45271086 (45.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7041  bytes 45379695 (45.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

E a rede que o DNS está rodando é a: br-936b043d07ecmas tenho medo que o nome dela também mude toda vez que eu executo docker-compose up(depois de terminar meu trabalho eu executo com frequência docker-compose down).

Muitas soluções como estaumsugerir resolução de DNSDENTROcontêiner docker. e isso não é o que eu quero, mas uma maneira de ter resolução de nomes curinga de maneira semelhante, eu poderia configurar domínios locais em /etc/hosts.

informação relacionada