Ok so when running separate docker containers each container is its own localhost so referencing localhost in the metricbeat container is not the localhost in the elasticsearch container.
This is docker stuff.
Perhaps look at
So when you want one container to communicate/connect with another container you need to use either the IP of the host or use
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.