Grafana docker-compose downloads plugins on every start

Sample docker-compose:

grafana:
image: grafana/grafana:5.2.4
ports:
- 3000:3000
environment:
- GF_INSTALL_PLUGINS=grafana-piechart-panel

IF I switch off the internet before starting grafana

Starting grafana_grafana_1 ... done
Attaching to grafana_grafana_1
grafana_1  | Failed to send requesterrorGet https://grafana.com/api/plugins/repo/grafana-piechart-panel: dial tcp: lookup grafana.com on 127.0.0.11:53: server misbehaving
grafana_1  | Error: ✗ Failed to send request. error: Get https://grafana.com/api/plugins/repo/grafana-piechart-panel: dial tcp: lookup grafana.com on 127.0.0.11:53: server misbehaving
grafana_1  | 
grafana_1  | NAME:
grafana_1  |    Grafana cli plugins install - install <plugin id> <plugin version (optional)>
grafana_1  | 
grafana_1  | USAGE:
grafana_1  |    Grafana cli plugins install [arguments...]
grafana_grafana_1 exited with code 1

If the plugin is downloaded once, then why is it downloading them everytime I start the docker-compose

Because it is a part of bootstrap image script, which is executed, when you start container:

This solves the problem but does not looks the best of solution http://docs.grafana.org/installation/docker/#building-a-custom-grafana-image-with-pre-installed-plugins

What is your problem? You have asked only why plugins are downloaded every time?

I understood the your post and its correct, I was wondering if there is a way to prevent that intelligently, like docker will never download grafana images again and again.

Upon researching I did find a way here using manual changes, but is there a better way?

Thanks

Use volume (docker volume or directory or volume from another container) for /pluginfolder in the container and run once Grafana container with:
GF_INSTALL_PLUGINS=... and GF_PLUGIN_DIR=/pluginfolder

It will install plugins to persistent storage, so next runs don’t need GF_INSTALL_PLUGINS variable (only GF_PLUGIN_DIR) and the internet won’t be required + you don’t need to manage own image. You will need GF_INSTALL_PLUGINS for plugin updates.

2 Likes

You can also build your custom Grafana docker image with your plugins

Just add the command to your Dockerfile

RUN grafana-cli plugins install your_plugin