大家好,又见面了,我是你们的朋友全栈君。
参考文章:从容器中获取宿主机IP地址
docker 中的程序需要连接外部的程序,连接的过程中会告知外部程序自己的ip地址,然后外部的程序会回连docker中的程序。由于docker使用的是rancher中的托管模式,外部程序是没办法直接连接到容器中的,那么如何解决呢?
-v
/proc:/hostip/:ro
--privileged
# 获取网络信息需要指定--net
nsenter --mount=/hostip/1/ns/mnt --net=/hostip/1/ns/net ip a
# 如果只是查看文件不需要指定--net
nsenter --mount=/hostip/1/ns/mnt ls /root
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/171599.html原文链接:https://javaforall.cn