docker运行Grafana图形化监控

首先查询一下grafana的镜像看看

[root@grafana ~]# docker search grafana/grafana
INDEX       NAME                                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/grafana/grafana                                    The official Grafana docker container           987                  
docker.io   docker.io/kamon/grafana_graphite                             All in one image running StatsD, Graphite ...   151                  
docker.io   docker.io/monitoringartist/grafana-xxl                       Dockerized Grafana 5.x/4.x/3.x with all pr...   74                   [OK]
docker.io   docker.io/samuelebistoletti/docker-statsd-influxdb-grafana   Docker Image with Telegraf (StatsD), Influ...   64                   [OK]
docker.io   docker.io/tutum/grafana                                      Grafana dashboard for InfluxDB. Please set...   57                   [OK]
docker.io   docker.io/fg2it/grafana-armhf                                Unofficial Grafana docker container for armhf   37                   
docker.io   docker.io/philhawthorne/docker-influxdb-grafana              A docker container to run InfluxDB and Gra...   10                   [OK]
docker.io   docker.io/appcelerator/grafana                               Grafana image based on Alpine linux             5                    [OK]
docker.io   docker.io/bitnami/grafana                                    Bitnami Docker Image for Grafana                3                    [OK]
docker.io   docker.io/grafana/loki                                       Loki - Cloud Native Log Aggregation by Gra...   3                    
docker.io   docker.io/luzifer/grafana                                    Automated build from Grafana Debian package     3                    [OK]
docker.io   docker.io/carlosedp/monitoring-grafana                       Grafana unofficial packages for ARM32 and ...   2                    
docker.io   docker.io/stefanprodan/swarmprom-grafana                     Docker Swarm Prometheus Grafana                 2                    
docker.io   docker.io/1and1internet/ubuntu-graphite-grafana              Graphite & Grafana                              1                    [OK]
docker.io   docker.io/rycus86/grafana                                    Grafana time series analytics software - g...   1                    [OK]
docker.io   docker.io/tcjennings/rpi-grafana                             Grafana for Raspberry Pi.                       1                    
docker.io   docker.io/wkulhanek/grafana                                  Grafana Docker Image for use with Red Hat ...   1                    
docker.io   docker.io/appcelerator/grafana-amp                           Grafana image customized for AMP                0                    [OK]
docker.io   docker.io/basi/grafana                                       Grafana with some limited automated data s...   0                    [OK]
docker.io   docker.io/grafana/grafana-enterprise                         Official Grafana Enterprise docker image        0                    
docker.io   docker.io/ibmcom/grafana                                     Docker Image for IBM Cloud Private-CE (Com...   0                    
docker.io   docker.io/igneoussystems/base-grafana                        Base image for grafana                          0                    
docker.io   docker.io/matisq/grafana                                     TIG Stack - Grafana                             0                    [OK]
docker.io   docker.io/rplan/grafana                                      customized grafana docker image                 0                    [OK]
docker.io   docker.io/rusn/grafana                                       Lightweight Grafana image                       0                    [OK]

编写Granfana的docker启动脚本

[root@grafana ~]# cat grafana.sh 
#!/bin/bash
basedir=$(cd `dirname $0`;pwd)

mkdir -p data # creates a folder for your data
ID=$(id -u) # saves your user id in the ID variable

docker stop grafana
docker rm grafana
docker run \
       -d --name grafana  -p 3000:3000 \
       -e "GF_SERVER_ROOT_URL=http://192.168.0.11" \  #覆盖ip
       -e "GF_SECURITY_ADMIN_PASSWORD=123456" \ #覆盖修改了密码
       --user $ID --volume "$PWD/data:/var/lib/grafana" \ #数据持久化挂载
       grafana/grafana grafana

#第一次执行启动脚本需要下载镜像
[root@grafana ~]# sh grafana.sh

登录
http://192.168.0.11:3000/login
admin
123456

推荐阅读更多精彩内容