[英]Docker host IP inside java program running in the container
是否有可能在docker容器中运行的java程序中获取docker主机IP?
From my understanding that docket from it's initial design is to isolate the host from containers. 据我了解,最初设计的目的是将主机与容器隔离。 Although this is doable, such as passing in a env variable to the container at startup, it is not a good practice.
尽管这是可行的,例如在启动时将env变量传递给容器,但这不是一个好习惯。 Try to containerize everything, and use a network and network links instead.
尝试将所有内容容器化,并改用网络和网络链接。 [Docker Compose maybe helpful]
[Docker Compose可能有帮助]
If you really need to do so for whatever reason here is a link for reference 如果您出于任何原因确实需要这样做,请点击此处链接
How to get the IP address of the docker host from inside a docker container 如何从Docker容器内部获取Docker主机的IP地址
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.