加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

从主机查询docker嵌入式dns

发布时间:2020-12-16 03:38:25 所属栏目:安全 来源:网络整理
导读:有没有人知道查询docker守护程序使用的嵌入式DNS服务器的方法.我正在尝试使用packetbeats,如果我可以用容器名称替换docker ip地址,那将会非常有用. 我目前可以想到的唯一方法是在容器中创建一个dns服务器,可以将其配置为主机的dns服务器,以确保主机可以解析

有没有人知道查询docker守护程序使用的嵌入式DNS服务器的方法.我正在尝试使用packetbeats,如果我可以用容器名称替换docker ip地址,那将会非常有用.

我目前可以想到的唯一方法是在容器中创建一个dns服务器,可以将其配置为主机的dns服务器,以确保主机可以解析容器名称.希望有道理吗?

这是唯一的方式还是有其他选择?

我正在尝试查询的容器是使用docker-compose创建的.

最佳答案
领事

我喜欢使用Hashicorp的领事.它可以作为已安装的客户端或容器运行,并提供可以在Docker外部查询的DNS接口.它还具有服务发现和功能等功能.监控,是开源的.

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!

对于你正在寻找的东西来说可能有点过头了,但应该做好这件事.

的dnsmasq

一个更简单的替代方案可能是DNSMasq.我对它不熟悉,但对于非常小的设置,它将允许您的主机知道运行容器的DNS.

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读