Loki: Document how to use the docker driver with a config file

Created on 26 Jun 2019  ·  13Comments  ·  Source: grafana/loki

We should document how to embed a configuration file within the Loki Docker driver.

Steps to rebuild the docker drivers with your config basically.

componendocs componenintegrations good first issue help wanted keepalive

Most helpful comment

Is it possible to add mounts to the plugin config? (as described here https://docs.docker.com/engine/extend/config/ and used in this plugin: https://github.com/vieux/docker-volume-sshfs). Then one could use 'docker plugin set' (https://docs.docker.com/engine/reference/commandline/plugin_set/ section about changing source of a mount).

All 13 comments

I can go through my shell history this evening (EU IST) for @raneq

Thank you @Strum355 , I can proofread and write what I miss for the README then :)

You guys are awesome ❤️

Unfortunately i havent been successful in getting it to work again, I had deleted the driver config.json and im getting the following errors trying to recreate what i had done (probably incorrectly):

 ~/G/loki   *…  make enable-plugin                                                                                                                                                                                                                                                                           
docker plugin enable grafana/loki-docker-driver:master-cb7c8f6
Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:430: container init caused \"rootfs_linux.go:58: mounting \\\"/home/noah/Netsoc/dev-env/nsa\\\" to rootfs \\\"/docker/plugins/3ce38f52d11d202d39bdc0289db39c062ef4280c23fb7a54a021f1b53c8143b8/rootfs\\\" at \\\"/docker/plugins/3ce38f52d11d202d39bdc0289db39c062ef4280c23fb7a54a021f1b53c8143b8/rootfs/home/noah/Netsoc/dev-env/nsa\\\" caused \\\"no such device\\\"\"": unknown

running make build-plugin didnt work a few times a well until i manually go get'd two packages :/

I tried to build it myself too. In a debian 9, in various iterations I've done:

git clone https://github.com/grafana/loki/
# make build-plugin → permission denied for docker
# sudo make build-plugin → make: go: Command not found

sudo apt install golang
# sudo make build-plugin →↓
# assets_generate.go:9:2: cannot find package "github.com/grafana/loki/pkg/promtail/server/ui" in any of:
#   /usr/lib/go-1.7/src/github.com/grafana/loki/pkg/promtail/server/ui (from $GOROOT)
#   ($GOPATH not set)
# assets_generate.go:10:2: cannot find package "github.com/prometheus/prometheus/pkg/modtimevfs" in any of:
#   /usr/lib/go-1.7/src/github.com/prometheus/prometheus/pkg/modtimevfs (from $GOROOT)
#   ($GOPATH not set)
# assets_generate.go:11:2: cannot find package "github.com/shurcooL/vfsgen" in any of:
#   /usr/lib/go-1.7/src/github.com/shurcooL/vfsgen (from $GOROOT)
#   ($GOPATH not set)

export GOPATH=/home/user/git/loki/
# sudo -E make build-plugin →↓
# CGO_ENABLED=0 go build -ldflags "-extldflags \"-static\" -s -w -X github.com/grafana/loki/vendor/github.com/prometheus/common/version.Branch=master -X github.com/grafana/loki/vendor/github.com/prometheus/common/version.Version=master-cb7c8f6 -X github.com/grafana/loki/vendor/github.com/prometheus/common/version.Revision=cb7c8f6" -tags netgo -o cmd/docker-driver/docker-driver ./cmd/docker-driver
# go: disabling cache (/go/cache) due to initialization failure: mkdir /go/cache/00: permission denied
# # github.com/grafana/loki/cmd/docker-driver
# cmd/docker-driver/config.go:56:3: cannot use "github.com/grafana/loki/vendor/github.com/cortexproject/cortex/pkg/util".BackoffConfig literal (type "github.com/grafana/loki/vendor/github.com/cortexproject/cortex/pkg/util".BackoffConfig) as type "github.com/grafana/loki/vendor/github.com/grafana/loki/vendor/github.com/cortexproject/cortex/pkg/util".BackoffConfig in field value
# cmd/docker-driver/config.go:127:19: cannot use "github.com/grafana/loki/vendor/github.com/cortexproject/cortex/pkg/util/flagext".URLValue literal (type "github.com/grafana/loki/vendor/github.com/cortexproject/cortex/pkg/util/flagext".URLValue) as type "github.com/grafana/loki/vendor/github.com/grafana/loki/vendor/github.com/cortexproject/cortex/pkg/util/flagext".URLValue in assignment
# cmd/docker-driver/loki.go:38:76: cannot use "github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".DefaultRegisterer (type "github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".Registerer) as type "github.com/grafana/loki/vendor/github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".Registerer in argument to stages.NewPipeline:
#   "github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".Registerer does not implement "github.com/grafana/loki/vendor/github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".Registerer (wrong type for MustRegister method)
#       have MustRegister(..."github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".Collector)
#       want MustRegister(..."github.com/grafana/loki/vendor/github.com/grafana/loki/vendor/github.com/prometheus/client_golang/prometheus".Collector)
# cmd/docker-driver/loki.go:58:40: cannot use l.labels.Clone() (type "github.com/grafana/loki/vendor/github.com/prometheus/common/model".LabelSet) as type "github.com/grafana/loki/vendor/github.com/grafana/loki/vendor/github.com/prometheus/common/model".LabelSet in argument to l.handler.Handle
# Makefile:158: recipe for target 'cmd/docker-driver/docker-driver' failed
# make: *** [cmd/docker-driver/docker-driver] Error 2
# make: Leaving directory '/go/src/github.com/grafana/loki'
# Makefile:141: recipe for target 'cmd/docker-driver/docker-driver' failed
# make: *** [cmd/docker-driver/docker-driver] Error 2

# So there's some programming error. Let's checkout a stable version then. Look, there's release v0.1.0
git stash 
git checkout v0.1.0 -b v0.1.0
git stash pop
# sudo -E make build-plugin → make: *** No rule to make target 'build-plugin'.  Stop.

Is there some meta-stable release that includes the docker plug-in and that I can use to build?
Thank you!

Unfortunately i havent been successful in getting it to work again

Thank you a lot @Strum355 for trying!!

Is there any ability to pass a config file without rebuilding the plugin?

@wapmorgan https://github.com/grafana/loki/issues/694#issuecomment-513870139
TLDR if you can enforce all configs being in a folder specified at build-time, its possible

@Strum355 at plugin build-time? Its really hard, because there can be few projects within one machine and one docker instance. If you mean image build-time, its possible.

@wapmorgan you can set the folder in which all config files will be set at plugin build-time eg /docker/loki/configs/ and then at container run-times you can specify which config file to use from that folder

@wapmorgan I could not find the answer on docker documentation.

This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

Is it possible to add mounts to the plugin config? (as described here https://docs.docker.com/engine/extend/config/ and used in this plugin: https://github.com/vieux/docker-volume-sshfs). Then one could use 'docker plugin set' (https://docs.docker.com/engine/reference/commandline/plugin_set/ section about changing source of a mount).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oleksandr-hyuna picture oleksandr-hyuna  ·  4Comments

arnitolog picture arnitolog  ·  6Comments

negbie picture negbie  ·  3Comments

ghostsquad picture ghostsquad  ·  3Comments

suppix picture suppix  ·  3Comments