This commit is contained in:
Zakary Timson 2022-06-02 15:09:23 -04:00
parent 2a5179cf74
commit 7386ea1274
3 changed files with 5 additions and 10 deletions

View File

@ -1,7 +1,6 @@
FROM prom/node-exporter:latest
USER root
COPY entrypoint.sh /etc/node-exporter/
RUN chmod +x /etc/node-exporter/entrypoint.sh
ENTRYPOINT [ "/etc/node-exporter/docker-entrypoint.sh" ]
CMD [ "/bin/node_exporter" ]
ENTRYPOINT ["sh", "/etc/node-exporter/entrypoint.sh"]
CMD ["/bin/node_exporter"]

View File

@ -4,7 +4,7 @@ This is a copy of [prom/node-exporter](https://hub.docker.com/r/prom/node-export
## Example
For the hostname to be detected, you must load the host filesystem into the container's `/host` directory as seen here.
For the hostname to be detected, you must mount the host's `rootfs` into the container's `/host` directory as seen here:
```
version: '3.8'
@ -21,5 +21,3 @@ services:
deploy:
mode: global
```
Otherwise use the `$HOSTNAME` variable to specify the path to the *hostname file* & ensure it's mounted.

View File

@ -1,8 +1,6 @@
#!/bin/sh
if [ -z "$HOSTNAME" ]; then $HOSTNAME="/host/hostname"; fi
NODE_NAME=$(cat "$HOSTNAME")
NODE_NAME=$(cat "/host/etc/hostname")
echo "node_meta{node_name=\"$NODE_NAME\"} 1" > /etc/node-exporter/node-meta.prom
set -- /bin/node_exporter "$@"
exec "$@"