Why does my metricbeat extension ignore my ActiveMQ broker host configuration in Kibana docker?

  activemq, docker, kibana, metricbeat

I’m trying to set up a local Kibana instance with ActiveMQ for testing purposes. I’ve created a docker network called elastic-network. I have 3 containers in my network: elasticsearch, kibana and finally activemq. In my kibana container, I downloaded metric beats using the following shell command

curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.11.2-linux-x86_64.tar.gz

In the configuration file metricbeat.reference.yml, I’ve changed the host for my ActiveMQ instance running under the container activemq

- module: activemq
  metricsets: ['broker', 'queue', 'topic']
  period: 10s
  hosts: ['activemq:8161']
  path: '/api/jolokia/?ignoreErrors=true&canonicalNaming=false'
  username: admin # default username
  password: admin # default passwor

When I run metricbeat using the verbose parameter ./metricbeat -e I get some error mentioning that ActiveMQ API is unreachable. My problem is that metricbeat ignore my active mq broker configuration and tries to connect to localhost.

Is there a reason why my configuration could be ignored?

Source: Docker Questions