简体   繁体   English

容器中运行的Java程序内部的Docker主机IP

[英]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.

相关问题 是否有使用 java 程序在 docker 容器内获取主机 Mac 和 ip 地址的方法 - Is there is anyway to get host Mac and ip address inside docker container using java progams 从 Java 程序内部运行 docker 容器 - Run a docker container from inside java program 如何:运行 java jar 的 Docker 容器连接到主机 mysql 服务器? - How to: Docker container running java jar connecting to host mysql server? Docker容器只能使用内部IP /端口访问在另一个容器中运行的MSSQL - Docker container is only able to access MSSQL running inside another container with the internal IP/port 有什么方法可以从 Java 程序内部检测它是否在 Docker 中运行? - Is there any way, from inside a Java program, to detect if its running in a Docker? 如何从主机外部(同一网络)连接到在 docker 容器内运行的 activemq 代理 [Windows] - How to connect to an activemq broker which is running inside a docker container from outside the host (same network) [Windows] 从 Docker 容器访问主机 Java - Accessing Host Java from Docker container Docker容器中的Java服务未连接到主机mysql - Java service in docker container not connecting to host mysql Java 堆在 docker 容器内 - Java heap inside docker container 在 Docker 映像中运行 Java 程序 - Running Java program in a Docker Image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM