sysulq / nginx-vts-exporter

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption
https://sysulq.github.io/nginx-vts-exporter/
MIT License
645 stars 142 forks source link

Resolver ignores /etc/hosts when running in Docker container #68

Closed seleznev closed 1 year ago

seleznev commented 6 years ago

Hello!

Looks like Go resolver uses /etc/nsswitch.conf, but busybox base image doesn't include them:

# docker run  -ti --rm --env NGINX_STATUS="http://localhost/status/format/json" --entrypoint=sh sophos/nginx-vts-exporter
/ # cat /etc/nsswitch.conf
cat: can't open '/etc/nsswitch.conf': No such file or directory

In this case resolver uses DNS first and ever "localhost" resolves via external DNS.

It isn't expected behaviour because other busybox utilities uses /etc/host for resolving.