继续进行docker改造。
1. 找镜像、拉取镜像
[root@devlop ~]# docker search grafana
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/grafana/grafana The official Grafana docker container 960 docker.io docker.io/kamon/grafana_graphite All in one image running StatsD, Graphite ... 150 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... 62 [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 36 docker.io docker.io/philhawthorne/docker-influxdb-grafana A docker container to run InfluxDB and Gra... 9 [OK] docker.io docker.io/appcelerator/grafana Grafana image based on Alpine linux 5 [OK] docker.io docker.io/istio/grafana 4 docker.io docker.io/luzifer/grafana Automated build from Grafana Debian package 3 [OK] docker.io docker.io/bitnami/grafana Bitnami Docker Image for Grafana 2 [OK]
2. 启动镜像
docker run -d -p 3000:3000 --name=grafana -v /data/grafana:/var/lib/grafana grafana/grafana
3. 查看日志
[root@devlop ~]# docker logs -f grafana GF_PATHS_DATA='/var/lib/grafana' is not writable. You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later mkdir: cannot create directory '/var/lib/grafana/plugins': Permission denied
发现报错,对'/var/lib/grafana/plugins'没有权限创建目录,那么就赋予权限:
chmod 777 /data/grafana
重启grafana
docker restart grafana
再次查看下日志,发现成功了
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
t=2018-12-10T07:45:50+0000 lvl=info msg="Starting Grafana" logger=server version=5.4.0 commit=69c5191 branch=HEAD compiled=2018-12-03T10:17:42+0000 t=2018-12-10T07:45:50+0000 lvl=info msg="Config loaded from" logger=settings file=/usr/share/grafana/conf/defaults.ini t=2018-12-10T07:45:50+0000 lvl=info msg="Config loaded from" logger=settings file=/etc/grafana/grafana.ini t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.data=/var/lib/grafana" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.logs=/var/log/grafana" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.paths.provisioning=/etc/grafana/provisioning" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from command line" logger=settings arg="default.log.mode=console" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_DATA=/var/lib/grafana" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_LOGS=/var/log/grafana" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PLUGINS=/var/lib/grafana/plugins" t=2018-12-10T07:45:50+0000 lvl=info msg="Config overridden from Environment variable" logger=settings var="GF_PATHS_PROVISIONING=/etc/grafana/provisioning" t=2018-12-10T07:45:50+0000 lvl=info msg="Path Home" logger=settings path=/usr/share/grafana t=2018-12-10T07:45:50+0000 lvl=info msg="Path Data" logger=settings path=/var/lib/grafana t=2018-12-10T07:45:50+0000 lvl=info msg="Path Logs" logger=settings path=/var/log/grafana t=2018-12-10T07:45:50+0000 lvl=info msg="Path Plugins" logger=settings path=/var/lib/grafana/plugins t=2018-12-10T07:45:50+0000 lvl=info msg="Path Provisioning" logger=settings path=/etc/grafana/provisioning t=2018-12-10T07:45:50+0000 lvl=info msg="App mode production" logger=settings t=2018-12-10T07:45:50+0000 lvl=info msg="Initializing HTTPServer" logger=server t=2018-12-10T07:45:50+0000 lvl=info msg="Initializing SqlStore" logger=server t=2018-12-10T07:45:50+0000 lvl=info msg="Connecting to DB" logger=sqlstore dbtype=sqlite3
4. 检查
访问http://172.28.64.10:3000/,成功的话会出现以下页面