If you want to start jstatd
on a specific port for its RMI registry, you can pass -p
parameter for this.
But the problem is that it opens a second random port (called "anonymous port" in java) which causes problem for writing firewall rules or to use JVisualVM to connect to a remote jstatd
running in a Docker container.
If you look at jstatd
source, you'll see that it is calling UnicastRemoteObject.exportObject(remoteHost, 0)
which will open a new "anonymous port" which seems to be random.
Is there a way to force this last port to a fixed one, or a way to predict which one will be chosen?