go-graphite / docker-go-graphite

Docker image for go-carbon + carbonapi + grafana
MIT License
31 stars 27 forks source link

How to change config files with docker assigned volumes? #9

Open spuder opened 4 years ago

spuder commented 4 years ago

Thanks for making these docker containers.

What is the recommended practice to change config files? Traditionally I've used the legacy 'bind' mount to point to files on the host managed by puppet.

docker run -it -v /etc/grafana/ldap.toml:/etc/grafana/ldap.toml gographite/go-graphite:1.0.4

However because this container uses the new volumes, I'm not able to use the older bind mounts.

https://docs.docker.com/storage/

If you mount a bind mount or non-empty volume into a directory in the container in which some files or directories exist, these files or directories are obscured by the mount, just as if you saved files into /mnt on a Linux host and then mounted a USB drive into /mnt. The contents of /mnt would be obscured by the contents of the USB drive until the USB drive were unmounted. The obscured files are not removed or altered, but are not accessible while the bind mount or volume is mounted.

Some people suggest using busybox to inject config files

https://stackoverflow.com/questions/37468788/what-is-the-right-way-to-add-data-to-an-existing-named-volume-in-docker

docker run -v my-jenkins-volume:/data --name helper busybox true
docker cp . helper:/data
docker rm helper

This feels unnecessarily complicated.

How do you recommend users change config files inside the docker container?

deniszh commented 4 years ago

Hi @spuder , Yes, for proper solution we need to support env variables, as Grafana doing that in own image. But why not copy whole https://github.com/go-graphite/docker-go-graphite/tree/master/conf/etc/grafana to directory, edit files and mount to /etc/grafana ?