Docker CIG

Posted by Vito on May 29, 2022

CIG

  • CAdvisor 监控收集
  • InfluxDB 存储数据
  • Grafana 图表展示

Install

  • 给 grafana 挂载目录授权
    1
    2
    3
    
    # grafana 容器未已 root 用户身份运行
    [root@mydockerhost cig]# mkdir -p /home/vito/docker/volume/cig_grafana/data/
    [root@mydockerhost cig]# chmod 777 /home/vito/docker/volume/cig_grafana/data/
    
  • 创建名为 cig 的目录,在目录中新建 docker-compose.yml 文件,内容如下:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    
    version: '3.8'
      
    #volumes:
    #  grafana_data: { }
      
    services:
      influxdb:
        #image: influxdb:2.2.0-alpine
        image: tutum/influxdb:0.9
        restart: always
        environment:
          - PRE_CREATE_DB=cadvisor
        ports:
          - "8083:8083"
          - "8086:8086"
        privileged: true
        volumes:
          - /home/vito/docker/volume/cig_influxdb/data:/data
        
      cadvisor:
        image: google/cadvisor:v0.33.0
        links:
          - influxdb:influxsrv
        command: -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influxsrv:8086
        restart: always
        ports:
          - "10580:8080"
        privileged: true
        volumes:
          - /:/rootfs:ro
          - /sys:/sys:ro
          - /var/lib/docker/:/var/lib/docker:ro
          - /var/run:/var/run:rw
        depends_on:
          - influxdb
        
      grafana:
        image: grafana/grafana:8.5.3
        user: "104"
        restart: always
        links:
          - influxdb:influxsrv
        ports:
          - "3000:3000"
        #privileged: true
        volumes:
          #- grafana_data:/var/lib/grafana
          - /home/vito/docker/volume/cig_grafana/data:/var/lib/grafana
        environment:
          - HTTP_USER=admin
          - HTTP_PASS=admin
          - INFLUXDB_HOST=influxsrv
          - INFLUXDB_PORT=8086
          - INFLUXDB_NAME=cadvisor
          - INFLUXDB_USER=root
          - INFLUXDB_PASS=root
        depends_on:
          - influxdb