I am trying to execute the following code in a Dockerfile:
FROM alpine:3.7
RUN apk update && apk add --no-cache busybox musl prometheus-node-exporter
RUN rc-update add prometheus-node-exporter default
RUN rc-service prometheus-node-exporter start
RUN echo " - job_name: node \
# If prometheus-node-exporter is installed, grab stats about the local \
# machine by default. \
static_configs: \
- targets: ['localhost:9100', 'alpine_distro:9100']" >> /etc/prometheus/prometheus.yml
but my build returns the following error:
ERROR:
unsatisfiable constraints:
prometheus-node-exporter (missing):
required by: world[prometheus-node-exporter]
The command '/bin/sh -c apk update && apk add --no-cache busybox musl prometheus-node-exporter' returned a non-zero code: 1
I am not used to Alpine package manager but my guess is that I might not be using a repo that contains prometheus-node-exporter
?
Or am I missing something else?
If from some reason you're forced to use Alpine 3.7, you could install the prometheus-node-exporter
package from the Alpine 3.13 community repo:
$ sudo docker run -it alpine:3.7
/ # apk add prometheus-node-exporter --repository=http://dl-cdn.alpinelinux.org/alpine/v3.13/community
fetch http://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/1) Installing prometheus-node-exporter (1.0.1-r0)
Executing prometheus-node-exporter-1.0.1-r0.pre-install
24% ###################################
Executing busybox-1.27.2-r11.trigger
OK: 20 MiB in 14 packages
/ #
/ #
/ # node_exporter --help
usage: node_exporter [<flags>]
...
It seems node_exporter
only depends on musl, so it's likely to work well without special issues:
/ # ldd /usr/bin/node_exporter
/lib/ld-musl-x86_64.so.1 (0x7fea4c68a000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fea4c68a000)
However, if you have that option, it's recommended to upgrade your base Alpine version to 3.13, instead.