Node Exporter docker container not working (HTTP 426) with `network_mode: host`

182 views Asked by At

I've been following the instructions from Node Exporter's official documentation and running Node Exporter in my Docker Compose project.

# compose.yaml

...
services:
  ...
  node-exporter:
    image: prom/node-exporter:v.1.7.0
    command:
      - '--path.rootfs=/host'
    network_mode: host
    pid: host
    restart: unless-stopped
    volumes:
      - /:/host:ro,rslave
...

This does start the container and the log doesn't show any error, but navigating to localhost:9100 gets me HTTP Error 426 "Upgrade Required". Same when querying the /metrics endpoint via curl, Postman or whatever.

If I replace network_mode: host with

ports:
  - 9100:9100/tcp

it works just fine. But then it it not clear to me if this is still ok (given the official docs' warning).

In other words the two questions are:

  1. Why is network_mode: host not working?
  2. What are the contraindications of not using it?

I am using Docker Desktop and WSL2 Ubuntu.

1

There are 1 answers

0
Daniele Repici On

Turns out host network driver is not supported in Docker Desktop.

This might answer question #1.