fg2it / grafana-on-raspberry

Grafana packages for raspberry pi (armv6/armv7) and aarch64/arm64
311 stars 32 forks source link

grafana ignoring grafana.ini? #13

Closed Naesstrom closed 7 years ago

Naesstrom commented 7 years ago

I've installed the docker image on my rpi3, then I made changes to etc/grafana.ini but when I start grafana it ignores the changes that I've made. Is the ini placed somewhere else when it's a docker image?

And one more thing, after I've run "docker run -d --name=grafana -p 3000:3000 fg2it/grafana-armhf:4.2.0" I can't run the other commands like: docker run \ -d \ -p 3000:3000 \ --name=grafana \ -e "GF_SERVER_ROOT_URL=http://grafana.server.name" \ -e "GF_SECURITY_ADMIN_PASSWORD=secret" \ fg2it/grafana-armhf:v4.1.2

That only gives me an error: docker: Error response from daemon: Conflict. The container name "/grafana" is already in use by container aa4432cbe755560aeabc16e4cf2d1f799cec238b49306b14c2e22ed17a6f6940. You have to remove (or rename) that container to be able to reuse that name.. See 'docker run --help'.

I'm starting grafana by docker start grafana since the docker run command only works once since I already have a container named grafana after the first run

trycoon commented 7 years ago

I'm not an expert, but exactly how do you make changes to /etc/grafana.ini? If that file exists within a container it will not be used when you make another "docker run", since that will create a new container. The only way to persist the /etc/grafana.ini-file between runs is to build a new image with this file as default, this can be archived with "docker build" or "docker commit". Another even better way is to mount an external "volume" with the config-file into the container, that way the changes to grafana.ini will not be lost when recreating containers. Like this:

Put your grafana.ini-file in your host machines /opt-directory, then run "docker run -d --name=grafana -v /opt/grafana.ini:/etc/grafana.ini -p 3000:3000 fg2it/grafana-armhf:4.2.0"

The /opt/grafana.ini file will be used as /etc/grafana.ini within the container.

As you have figured out, you can't have more than one container with the same name. You should never run both commands, if you want to pass on additional parameter then use the second one and and not the first one. Begin from the beginning by deleting your docker container "docker rm -f grafana", and the just run the second example.

Naesstrom commented 7 years ago

yup, I deleted the docker and just used the bintray repo instead, thats more old fashioned like me :D

fg2it commented 7 years ago

Let start with the second problem : as pointed out by trycoon, you cannot have 2 different containers with the same name. When you run

docker run -d --name=grafana -p 3000:3000 fg2it/grafana-armhf:4.2.0

This creates (and run) a container named grafana (the --name= option). If you don't remove this container (stopping it is not enough) and run

 docker run -d -p 3000:3000 --name=grafana -e "GF_SERVER_ROOT_URL=http://grafana.server.name" -e "GF_SECURITY_ADMIN_PASSWORD=secret" fg2it/grafana-armhf:v4.1.2

docker complains because this try to create a new container, also named grafana. Change the name in --name= and you should be good to go. E.g. this should work

 docker run -d -p 3000:3000 --name=grafana2 -e "GF_SERVER_ROOT_URL=http://grafana.server.name" -e "GF_SECURITY_ADMIN_PASSWORD=secret" fg2it/grafana-armhf:v4.1.2

For your first problem, how do you change /etc/grafana/grafana.ini? Once more, Trycoon is right. If you change grafana.ini in a container, you will see changes only in this container. By the way, you could probably avoid changes in grafana.ini with -e option. See the official grafana docker image doc and the grafana config doc.