Not finding anything on the University of Google so checking here. I have an enterprise application running on an application server inside a docker image. During the running time, the enterprise application needs to use a Java API call to obtain the Docker Container Id that it's running in. How is this done?
In general, when docker runs a container it should set the hostname with the id of the container, so just reading the environment variable HOSTNAME
(or the file /etc/hostname
) should do it.
If this does not work, provide more information about your setup.