Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker deployment without host networking #62

Open
matutter opened this issue Jun 27, 2021 · 2 comments
Open

Docker deployment without host networking #62

matutter opened this issue Jun 27, 2021 · 2 comments

Comments

@matutter
Copy link

Is there a method to run the mindflavor/prometheus-wireguard-exporter docker image without requiring network_mode: host ?

The purpose would be to allow only prometheus running in a container access the exporter and not expose the API to the host.

version: "3.7"

networks:
  monitor-net:

services:
  wgexporter:
    container_name: wgexporter
    image: mindflavor/prometheus-wireguard-exporter
    restart: unless-stopped
    # Would prefer to just export metrics to other containers on the docker network.
    # expose:
    #   - 9586
    # networks:
      # - monitor-net
    # But cannot run `wg show` without this
    network_mode: host
    cap_add:
      - NET_ADMIN
    labels:
      org.label-schema.group: "monitoring"
@shizunge
Copy link

Try https://github.com/qoomon/docker-host
Docker image to forward TCP and UDP traffic to the docker host.

@arisudesu
Copy link
Contributor

arisudesu commented Jul 18, 2021

Try binding to docker internal address then adding this address as an extra host for prometheus:

Mine looks like:

services:
  prometheus:
    container_name: prometheus
    build: prometheus
    extra_hosts:
      - 'wireguard-exporter:172.17.0.1'  # notice the extra host

  wireguard-exporter:
    container_name: wireguard-exporter
    image: 'mindflavor/prometheus-wireguard-exporter:3.5.1'
    command:
      - '-a'
      - '-l=172.17.0.1'  # notice the listen addr
      - '-p=9200'
      - '-n=/etc/wireguard/wg0.conf'
    network_mode: host
    volumes: [ /etc/wireguard/wg0.conf:/etc/wireguard/wg0.conf:ro ]
    cap_add: [ NET_ADMIN ]

This way the exporter should be available on docker network to prometheus.

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

No branches or pull requests

3 participants