Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Node exporter not starting through docker service create #128

Open
greenenvy2 opened this issue Jul 4, 2020 · 1 comment
Open

Node exporter not starting through docker service create #128

greenenvy2 opened this issue Jul 4, 2020 · 1 comment

Comments

@greenenvy2
Copy link

It's probably more of a question than a problem, but i don't understand why it happens. When i run the node-exporter through docker stack deploy everything works fine, but when i'm trying to use it through docker service create it does not work and spills out the following error:

time="2020-07-04T03:07:13Z" level=info msg="Starting node_exporter (version=0.16.0, branch=HEAD, revision=d42bd70f4363dced6b77d8fc311ea57b63387e4f)" source="node_exporter.go:82" time="2020-07-04T03:07:13Z" level=info msg="Build context (go=go1.9.6, user=root@a67a9bc13a69, date=20180515-15:52:42)" source="node_exporter.go:83" time="2020-07-04T03:07:13Z" level=fatal msg="Couldn't create collector: failed to open sysfs: could not read /host/sys: stat /host/sys: no such file or directory" source="node_exporter.go:88"

docker-compose.yml (works):

version: "3.3"

networks:
  net:
    driver: overlay

services:
  node-exporter:
    image: stefanprodan/swarmprom-node-exporter:v0.16.0
    networks:
      - net
    environment:
      - NODE_ID={{.Node.ID}}
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
      - /etc/hostname:/etc/nodename
    command:
      - '--path.sysfs=/host/sys'
      - '--path.procfs=/host/proc'
      - '--collector.textfile.directory=/etc/node-exporter/'
      - '--collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'
      - '--no-collector.ipvs'
    deploy:
      mode: global
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 64M

docker service create (does not work, spilling out the mentioned error):

#!/bin/bash

docker network create --driver overlay master --subnet 172.30.0.0/16

docker service create \
    --name node-exporter \
    --network master \
    --env NODE_ID={{.Node.ID}} \
    --mount type=bind,source=/proc,destination=/host/proc:ro \
    --mount type=bind,source=/sys,destination=/host/sys:ro \
    --mount type=bind,source=/,destination=/rootfs:ro \
    --mount type=bind,source=/etc/hostname,destination=/etc/nodename \
    --mode global \
    --limit-memory=128MB \
    --reserve-memory=64MB \
    stefanprodan/swarmprom-node-exporter:v0.16.0 \
    --path.sysfs=/host/sys \
    --path.procfs=/host/proc \
    --collector.textfile.directory=/etc/node-exporter/ \
    --collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)" \
    --no-collector.ipvs

Docker version:

Docker version 19.03.8, build afacb8b7f0

Thanks in advance.

@andyle83
Copy link

Should run as su

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants