version: '3'

services:

  node_exporter:
    image: prom/node-exporter:latest
    container_name: node_exporter
    command:
      - '--path.rootfs=/host'
    pid: host
    user: root
    restart: unless-stopped
    environment:
      - TZ=Asia/Shanghai
    ports:
      - 9100:9100
    volumes:
      - '/:/host:ro,rslave'

  prometheus:
    image: prom/prometheus:latest
    restart: always
    container_name: prometheus
    hostname: prometheus
    environment:
    - TZ=Asia/Shanghai
    ports:
    - 9090:9090
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries' 
      - '--web.console.templates=/usr/share/prometheus/consoles' 
      - '--storage.tsdb.retention.time=7d'
      - '--web.external-url=prometheus'
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      - ./promdata:/prometheus
