在Docker for Mac上,从容器看到的是主机ip? [英] On Docker for Mac what would be the host ip as seen from the container?

查看:197
本文介绍了在Docker for Mac上,从容器看到的是主机ip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的容器上设置调试器,这需要我设置远程(docker主机)IP。在不同的教程中,我找到列出的不同IP地址作为可能的解决方案。在我的容器中,我运行一个网络服务器,显示我从主机的容器连接来自 172.19.0.1 。这是在Docker for Mac版本 1.11.x 。但是,如何从Docker for Mac上的容器中看到主机IP的可靠性?什么时候可以改变这个IP?



编辑:
重复的 https://stackoverflow.com/a/24716645/6309

解决方案

您可以通过运行以下命令从容器中获取主机的ip:

  / sbin / ip route | awk'/ default / {print $ 3}'


I need to setup a debugger on my container, that requires me to set the remote (docker host) IP. In different tutorials I find different IP addresses listed as possible solution. In my container I ran a webserver that showed me that connections made to the container from my host machine come from 172.19.0.1. This is on Docker for Mac version 1.11.x.

But how would I reliably find out the host IP as seen from the container on Docker for Mac? When would it be possible for this IP to change?

Edit: Duplicate of https://stackoverflow.com/a/24716645/6309

解决方案

You can get the ip of the host from within the container by running this command:

/sbin/ip route|awk '/default/ { print $3 }'

这篇关于在Docker for Mac上,从容器看到的是主机ip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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