Unable to get Metricbeat to communicate with Elasticsearch

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

host.docker.internal