如何将主机名从主机解析为Docker容器? [英] How do I resolve hostnames to Docker containers from the host?

查看:177
本文介绍了如何将主机名从主机解析为Docker容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解Docker在127.0.0.11上运行了一个神奇的dns,所以我想我会尝试

I understand Docker runs a magical dns on 127.0.0.11, so I figured I'd try

nslookup mycontainername 127.0.0.11

当然,其中 mycontainername 是我尝试访问的容器的名称。

where mycontainername is, of course, the name of the container I'm trying to access. However, that timed out.

;; connection timed out; no servers could be reached

我在做什么错?我使用Docker 1.10.3。如果有帮助,我将使用 docker-compose 1.6.2拉起一堆容器。

What am I doing wrong? I'm on Docker 1.10.3. If it helps, I'm pulling up a bunch of containers using docker-compose 1.6.2.

编辑,这是 Docker 1.10通过主机的主机名访问容器

推荐答案

出色的解决方案,已在这篇文章中得到解答: https://stackoverflow.com/a/51125399/9270227 。它基本上只是一个名为 docker-hoster 的轻量级容器,它可以为您完成所有繁重的工作。

There is an excellent solution for this and it has been answered in this post: https://stackoverflow.com/a/51125399/9270227. It is basically just a lightweight container called docker-hoster that does all the heavy lifting for you.

这篇关于如何将主机名从主机解析为Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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