0

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?

β.εηοιτ.βε
  • 33,893
  • 13
  • 69
  • 83
Bluz
  • 5,980
  • 11
  • 32
  • 40
  • 2
    Alpine 3.7 is quite an old version tbh, is there a valid reason for you using it? For your information, it is not support anymore since More than a year: https://alpinelinux.org/releases/ – β.εηοιτ.βε Feb 11 '21 at 18:56
  • `that I might not be using a repo that contains prometheus-node-exporter?` yes. – KamilCuk Feb 11 '21 at 19:02
  • https://pkgs.alpinelinux.org/packages?name=prometheus-node-exporter&branch=v3.7 there is no such package in 3.7. Use latest alpine. – KamilCuk Feb 13 '21 at 20:19

1 Answers1

2

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.

valiano
  • 16,433
  • 7
  • 64
  • 79