从主机查询Docker嵌入式DNS [英] Query docker embedded dns from host

查看:155
本文介绍了从主机查询Docker嵌入式DNS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道查询docker守护进程使用的嵌入式dns服务器的方法吗?我正在试验packetbeats,如果可以用容器名称替换docker ip地址,这将非常有用。

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 addresses with the container names.

我目前唯一想到的方法是在可以配置为主机的dns服务器的容器中创建dns服务器,以确保主机可以解析容器的名称。希望这有意义吗?

The only way I can currently think of to achieve this is to create a dns server in a container that can be configured as the dns server for the host to ensure container names can be resolved by the host. Hope that makes sense?

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

Is this the only way or are there other options ?

我的容器m尝试查询是使用docker-compose创建的。

The containers I'm trying to query were created using docker-compose.

推荐答案

领事


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

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


Consul的主要查询接口之一是DNS。 DNS接口允许应用程序使用服务发现,而无需与Consul进行任何高度接触的集成。

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.

例如,主机可以使用DNS服务器来代替向Consul发出HTTP API请求直接通过名称查询(例如 redis.service.east-aws.consul)进行。该查询自动转换为查找提供redis服务的,位于 east-aws节点中的节点。数据中心,并且没有运行状况检查失败。就是这么简单!

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。我不太熟悉,但是对于很小的设置,它将使您的主机可以DNS识别正在运行的容器。

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/

这篇关于从主机查询Docker嵌入式DNS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆