Skip to content

docker-compose.yml example #77

@debuglevel

Description

@debuglevel

As it took me quite a while to figure out the permission stuff how to run systemd_exporter with the docker image (https://hub.docker.com/r/prometheuscommunity/systemd-exporter), I would just like to document my solution here.

Typical errors were:

caller=systemd.go:247 level=error msg="error collecting metrics" err="couldn't get dbus connection: read unix @->/run/systemd/private: read: connection reset by peer"

caller=systemd.go:247 level=error msg="error collecting metrics" err="couldn't get dbus connection: write unix @->/run/systemd/private: write: broken pipe"

caller=collector.go:169 level=error msg="collector failed" name=systemd err="couldn't get dbus connection: dial unix /var/run/dbus/system_bus_socket: connect: no such file or directory"

couldn't get dbus connection: write unix @: sendmsg: broken pipe
version: '3.2'
services:
  node-exporter:
    container_name: systemd-exporter
    image: prometheuscommunity/systemd-exporter:v0.5.0
    command:
      - "--log.level=debug"
      - "--path.procfs=/host/proc"
      - "--web.listen-address=127.0.0.1:9558"
      - "--systemd.collector.private"  # Use systemd socket instead of DBus
    network_mode: "host"  # Does not need port specification therefore
    
    # We need either "privileged: true" (DBus connection) or "user: root" (systemd socket connection). Pick your poison.
    #privileged: true  # Needed to connect to DBus.
    user: "root"  # Needed to connect to systemd socket. 

    pid: "host"
    volumes:
      - type: "bind"
        source: "/proc"
        target: "/host/proc"
        read_only: true
      - type: "bind"
        source: "/run/systemd"
        target: "/run/systemd"
        read_only: true
      - type: "bind"
        source: "/var/run"
        target: "/var/run"
        read_only: true
      - type: "bind"
        source: "/sys/fs/cgroup"
        target: "/sys/fs/cgroup"
        read_only: true
    restart: unless-stopped

I'm not sure though if really all that binds are needed or could be at least a bit more specific (e.g. only /var/run/systemd/private).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions