Docker.github.io: Prometheus in service task can't talk to host metrics via "localhost"

Created on 15 Oct 2017  路  9Comments  路  Source: docker/docker.github.io

File: engine/admin/prometheus.md, CC @mstanleyjones

This docker engine metrics shows a prometheus.yml file that points to localhost for engine metrics on linux. However, from the prom container, it can't access host's localhost, only the containers localhost, and gets a connection refused.

Not sure the best way to get a swarm service to see the localhost IP of the engine.

areEngine

Most helpful comment

please update the docs. its not working!

All 9 comments

Run with --net=host probably. That will bind the port on the Docker host directly. Can you give it a try and let me know?

passing --network=host
container cannot be disconnected from host network or connected to host ne...

in a swarm i dont think you cant pass host network
i tried from container (also as "metrics-addr": "0.0.0.0:9323")
nc -zv 172.19.0.1 9323
nc -zv 172.17.0.1 9323

no answer

it is a forward problem: it is supposed i call metrics from external passing from ingress

it works just not as service. Boh too many parameters but i dont see the more important
node cpu,disk,memory,bandwidth usage. I dont convince me

Closing this ticket due to its age, and the impending refactor. If you think this is in error, feel free to reopen. Thanks!

Sorry for reopening this, but documentation is wrong and should be corrected.
As previous people have said, you can only connect to the docker metrics through container's localhost if you use the hosts network, which doesn't look very doable in a production environment, IMO.

Could you provide the standard way to do this by fixing the documentation?

Thanks a lot!

On Mac/Windows you can use host.docker.internal to connect to localhost because --net=host only works on Linux. However, I completely agree with @johnyserpa. There has to be a standard way to implement this functionality in a production environment

please update the docs. its not working!

Always not working!

What is the correct way of doing this in Docker Swarm mode?

Was this page helpful?
0 / 5 - 0 ratings