Skip to content
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.

Remove VOLUME declaration from Dockerfile (or propose method for changing config on a remote docker host) #50

Closed
pydolan opened this issue Sep 8, 2016 · 5 comments
Assignees

Comments

@pydolan
Copy link

pydolan commented Sep 8, 2016

If I use grafana-docker on a remote docker host (e.g., via docker-machine), as far as I can tell, I cannot change the grafana config files/directories without uploading those files to the remote docker host first (since volume declarations are with regards to the remote host).

With other docker images (e.g., the official nginx image), I can create a Dockerfile that extends the official image, and then use COPY commands to change the config files I want.

When I try this custom Dockerfile with grafana (i.e., that starts with FROM grafana/grafana:latest), my commands that change the grafana config directories have no effect. From what I understand, this is because the volumes are initialized after the Dockerfile is processed, so any changes done to the locations is overwritten when the volumes are mounted.

Example of what I'm trying to do:

FROM grafana/grafana:latest

# copy grafana.ini file that enables dashboards.json setting:
COPY grafana.ini /etc/grafana/
RUN mkdir -p //var/lib/grafana/dashboards
COPY dashboards/ /var/lib/grafana/dashboards/

I'm assuming that the VOLUME command is used to prevent losing of any config changes done via the grafana web UI, but I suspect that there are only a handful of files/directories that are changed by the grafana web UI (e.g. the sql database).

I propose we remove many of the volumes from the grafana Dockerfile so that my above use-case can be accomplished. At the very least, have /etc/grafana not in there so that grafana.ini can be overwritten. THen, for the files that are changed regularly via the grafana web UI (e.g., grafana's sqlite db), continue to have a volume for these (or move the files to a new directory that doesn't conflict with grafana's config directories and make that a docker volume).

Thoughts?

@mkjaer
Copy link

mkjaer commented Feb 13, 2017

The same is true when trying to create an image with plugins.

I had to go around it like this:

FROM grafana/grafana:4.1.1
ENV PLUGINSDIR /grafana/plugins
RUN grafana-cli --pluginsDir ${PLUGINSDIR} plugins install alexanderzobnin-zabbix-app && \
    grafana-cli --pluginsDir ${PLUGINSDIR} plugins install grafana-kairosdb-datasource && \
    sed -i "s|;plugins.*|plugins = ${PLUGINSDIR}|g" /etc/grafana/grafana.ini```

@mohsen0
Copy link

mohsen0 commented Feb 16, 2017

That is a serious issue that prevents people from having a stateless grafana.
Since by pushing a new image into live envinment with the new configuration, when the container gets recreated, the volume does not get recreated and old settings remain in the container which is a problem.

@ds17f
Copy link

ds17f commented Feb 20, 2018

This issue also has an impact on persistent volumes in kubernetes. If you mount a persistent volume at /var/ the actual files you want to persist are not written to the persisted volume. They're instead housed in docker volumes and do not persist beyond container crashes. More can be found here:

https://plus.google.com/+AaronRoydhouse/posts/E3Ag8EPMgkp

Given the age of this issue and the lack of discussion, is this a "wontfix"?

@ds17f
Copy link

ds17f commented Feb 20, 2018

Wanted to follow up after a few hours of work.

It turns out that you can mount kubernetes volumes OVER the docker mount points and the data will end up in the kubernetes volume.

So instead of mounting /var to a kubernetes volume, I found success by mounting /var/grafana/lib and /var/grafana/log to kubernetes volumes. The data then persisted between container restarts.

@xlson xlson self-assigned this Mar 29, 2018
@xlson
Copy link
Contributor

xlson commented Mar 29, 2018

All volumes have been removed in #146. This image will be released with Grafana 5.1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants