Open
Description
Hi,
It would appear that there is some issue with handling the hosts
file, or name resolution (resolv.conf
) when hosts are provided via the --add-host
switch in docker, or in an equivalent docker_compose file (Adding the host to ExtraHosts
in docker inspect
).
Specifically; When I run the image: wrouesnel/postgres_exporter:latest
with the database host defined as db01
via --add-host
, the container produces the following error in the log:
time="2019-07-11T11:00:49Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1437"
time="2019-07-11T11:00:50Z" level=info msg="Established new database connection to \"db01:5432\"." source="postgres_exporter.go:777"
time="2019-07-11T11:00:50Z" level=error msg="Error opening connection to database (postgresql://django:PASSWORD_REMOVED@db01:5432/django?sslmode=disable): dial tcp 178.23.178.19:5432: connect: connection refused" source="postgres_exporter.go:1336"
While running the exact same setup, but with the image: magentadk/postgres_exporter:latest
produces the following output:
time="2019-07-11T11:10:04Z" level=info msg="Established new database connection to \"db01:5432\"." source="postgres_exporter.go:777"
time="2019-07-11T11:10:05Z" level=info msg="Semantic Version Changed on \"db01:5432\": 0.0.0 -> 10.9.0" source="postgres_exporter.go:1229"
time="2019-07-11T11:10:05Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1437"
Where the image magentadk/postgres_exporter:latest
is defined by the following Dockerfile
:
FROM wrouesnel/postgres_exporter
FROM debian:10
RUN useradd -u 20001 postgres_exporter
USER postgres_exporter
COPY --from=0 /postgres_exporter /postgres_exporter
EXPOSE 9187
ENTRYPOINT [ "/postgres_exporter" ]