//以下内容直接复制到 docker-compose.yml 文件中。执行命令docker-compose up -d 之后访问 http://ip:3000 剩下的之后的测试连接数据库和监控自己百度

version: '3'

services:
    influxdb:
        image: tutum/influxdb:0.9
        container_name: influxdb
        restart: always
        environment:
             - PRE_CREATE_DB=cadvisor
        ports:
             - "8083:8083"
             - "8086:8086"
        expose:
             - "8090"
             - "8099"
        volumes:
             - influxdbData:/data
    cadvisor:
        image: google/cadvisor
        container_name: cadvisor
        links:
             - influxdb:influxsrv
        command: -storage_driver=influxdb -storage_driver_db=cadvisor -storage_driver_host=influxsrv:8086
        restart: always
        ports:
             - "8080:8080"
        volumes:
             - /:/rootfs:ro
             - /var/run:/var/run:rw
             - /sys:/sys:ro
             - /var/lib/docker/:/var/lib/docker:ro
    grafana:
        image: grafana/grafana
        container_name: grafana
        restart: always
        links:
             - influxdb:influxsrv
        ports:
             - "3000:3000"
        environment:
             - HTTP_USER=admin
             - HTTP_PASS=admin
             - INFLUXDB_HOST=influxsrv
             - INFLUXDB_PORT=8086
             - INFLUXDB_NAME=cadvisor
             - INFLUXDB_USER=root
             - INFLUXDB_PASS=root

volumes:
    influxdbData: