Prometheus JMX Exporter in Tomcat

I am trying to configure and use the Prometheus JMX Exporter in Camunda 7.18, Tomcat, using the Docker Container. I am following the instructions here: https://github.com/camunda/docker-camunda-bpm-platform/blob/next/README.md#prometheus-jmx-exporter.

I have followed the instructions for configuring Docker, as shown in the excerpt below:

camunda:
    image: camunda/camunda-bpm-platform:tomcat-7.18.0
    container_name: camunda
    environment:
      ...
      - JMX_PROMETHEUS=true
    volumes:
     ...
      - "./camunda/configuration/prometheus-jmx.yml:/camunda/javaagent/prometheus-jmx.yml"
    ports:
      - "8080:8080"
      - "9404:9404"

The file prometheus-jmx.yml contains the following:

rules:
- pattern: ".*"

When starting the container, I see in the logs this message:
Enabling Prometheus JMX Exporter on port 9404

However, when attempting to access http://localhost:9404/metrics, I get no data back and get the error “socket hangup”.

Should this be working? Am I missing something?