I have a Jmeter 5.3 container that runs a basic .jmx test. Within the test is Johrstrom's Prometheus plugin, configured for port 9270. If I run the test outside of Docker, I can use 'curl localhost:9270' to get the metrics. It's similar when I run the test inside Docker. If I go to the JMeter Docker command line, I can run 'wget localhost:9270' (curl isn't in the image) and it gives me the metrics.
Still in the JMeter Docker container, if I do 'wget jmeter:9270' (jmeter is the name of the container) I get connection refused. The response does include
Resolving jmeter (jmeter)... 172.18.0.3
So I'm happy that it's not a failure due to the container name. I also have Prometheus running in a separate container, having a target configured for 'jmeter:9270' gives a similar response, the correct resolution of the jmeter name but then connection refused message.
I have also tried exposing port 9270, and trying the same 'localhost:9270' from the Docker host. That doesn't work either, I get empty reply from server.
What have I missed in the configuration that is preventing me from connecting between containers? Or even why I get 'connection refused' within the same container.
I should mention that I'm following the instructions on the Prometheus listener page and adding the following property to JMeter in the container.
-Jprometheus.ip=0.0.0.0
However I have also tried without this setting and I still get connection refused.