我想从 mac 上的 docker 容器访问主机 IP 地址。我知道如何使用 bridge0 接口(interface)在 Linux 上做到这一点。但是 docker for mac 没有bridge0。我尝试使用网关 172.17.0.1 在 docker 容器中,但它不起作用。
我的 docker for mac 版本是 Docker version 1.13.0, build 49bf474 .
我看了这个链接 https://github.com/docker/docker/issues/22753 但它提到在 lo0 接口(interface)上创建一个我不想的别名。因为我们的项目是在 docker 容器中运行的,我想提供一种通用的方法,而无需更改主机上的任何内容。
有谁知道如何在Mac中做到这一点?
Best Answer-推荐答案
来自 Docker documentation :
I WANT TO CONNECT FROM A CONTAINER TO A SERVICE ON THE HOST
The Mac has a changing IP address (or none if you have no network
access). From 17.06 onwards our recommendation is to connect to the
special Mac-only DNS name docker.for.mac.localhost which will resolve
to the internal IP address used by the host.
我认为您需要升级您的 Docker For Mac 版本才能使其正常工作。
关于docker - 如何从 docker 容器获取 mac 主机 IP 地址?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/41886752/
|