If you're using Java Spring Boot, you can set the server port the application runs on to any port, but also to a random port:
server:
port: 0
However, when I now use a Dockerfile for my application, I won't know what port to EXPOSE. Is there any way to find this port?