Docker container get Host IP address <p>How do I get the Host IP address within an Java application running inside a Docker?</p> <p>Obviously, if I use the traditional InetAddress.getLocalHost(), it works if the Java program runs directly on the Host. However, if it is running inside a container, then it would not be the physical ip address outside world sees the host.</p> <p>My use case is that my Java application registers itself as a service provide by inserting into a shared registry (like a database table) with informations like service name, ip address and port number so that others can find and invoke the service.</p> <p>Someone mentioned the only way is through run --env when you start the container, but how do my Java program gets it? If I have a way to retrieve it from Java, that would work though it looks ugly .....</p>