Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use grafana-cli on docker installed Grafana?

I have installed grafana via docker.

Is it possible to export and run grafana-cli on my host?

like image 950
northtree Avatar asked Aug 09 '17 02:08

northtree


3 Answers

For a full automatic setup of your Grafana install with the plugins you want I would follow Ricardo's suggestion. Its much better if you can configure your entire container as wanted in a single hit like that.

However if you are just playing with the plugins and want to install some manually, then you can access a shell on the running docker instance from the host.

host:~$ docker exec -it grafana /bin/bash

... assuming you named the docker container "grafana" otherwise you will need to substitute the given container name. The shell prompt that returns will allow you to run the standard

root@3e04b4578ebe:/# grafana-cli plugins install ....

Be warned that it may tell you to run service grafana-server restart afterwards. In my experience that didn't work (Not sure it runs as a traditional service in the container). However if you exit the container, and restart the container from the host...

host:~$ docker restart grafana

That should restart the grafana service and your new plugins should be in place.

like image 120
Vagnerr Avatar answered Sep 22 '22 05:09

Vagnerr


If you meant running Grafana with some plugins installed, you can do it by passing a list of plugin names to a variable called GF_INSTALL_PLUGINS.

sudo docker run -d -p 3000:3000 -e "GF_INSTALL_PLUGINS=gridprotectionalliance-openhistorian-datasource,gridprotectionalliance-osisoftpi-datasource" grafana/grafana

I did this on Grafana 4.x

Installing plugins for Grafana 3 "or above"

like image 25
Ricardo Avatar answered Sep 24 '22 05:09

Ricardo


Grafana running in docker container

Docker installed on Windows 10

Test: command to display grafana-cli help

c:\>docker exec -it grafana grafana-cli --help

Tested with a version: Version 6.4.4 November 6, 2019

like image 31
Edvaldo Silva Avatar answered Sep 23 '22 05:09

Edvaldo Silva