Query docker embedded dns from host

后端 未结 3 807
太阳男子
太阳男子 2021-02-05 18:14

Does anybody know a way to query the embedded dns server that the docker daemon uses. I\'m experimenting with packetbeats and it would be useful if I could replace docker ip add

3条回答
  •  花落未央
    2021-02-05 19:06

    Consul

    I like using Hashicorp's Consul for this. It can run as an installed client or container, and provides a DNS Interface that you can query external of Docker. It also has features like service discovery & monitoring, and is open source.

    https://www.consul.io/docs/agent/dns.html

    One of the primary query interfaces for Consul is DNS. The DNS interface allows applications to make use of service discovery without any high-touch integration with Consul.

    For example, instead of making HTTP API requests to Consul, a host can use the DNS server directly via name lookups like "redis.service.east-aws.consul". This query automatically translates to a lookup of nodes that provide the redis service, are located in the "east-aws" datacenter, and have no failing health checks. It's that simple!

    It might be overkill for what you're looking for, but should do the job.

    DNSMasq

    A simpler alternative might be DNSMasq. I'm not as familiar with it, but for a really small scale setting it would allow your host to be DNS aware of running containers.

    http://www.thekelleys.org.uk/dnsmasq/doc.html

    https://hub.docker.com/r/andyshinn/dnsmasq/

提交回复
热议问题