I am creating a instance of my image like
docker run -P webmodule-xy
The Dockerfile for the webmodule exposes a port (e.g. 8080).
My goal now is to obtain the mapped / assigned port number which is accessible from the outside via Java. Is there a environment variable or something like that?
Usecase: The webmodule-xy should register itself on another web-application and provide its IP + Port so the other application can contact the webmodule-xy later on. IP is no problem, but the port is.
I already found this open issue on GitHub, but I can't believe that there is no simple solution. Like stated there, REST is not an option:
Allowing a container to have access to the REST API is problematic. For one thing, the REST API is read/write, and if all you need is to read your portmappings, that's a dangerous level of permissions to grant a container just to find out a few ports.