Dgraph cannot find my config file

I am running Dgraph on docker. Running this command from the docs to start zero -

docker run -it -p 5080:5080 --network dgraph_default -p 6080:6080 -v ~/zero:/dgraph dgraph/dgraph:latest dgraph zero --my=HOSTIPADDR:5080

works fine. Now I wanted to have a config file where I can provide the flags that I want to start zero/alpha with. I created a config.yaml file in the same directory -

my: "localhost:5080"

Note that this is in the same directory. Now if I run docker run -it -p 5080:5080 --network dgraph_default -p 6080:6080 -v ~/zero:/dgraph dgraph/dgraph:latest dgraph zero --config config.yaml , it reports the following error -

[Decoder]: Using assembly version of decoder
2020/04/30 11:35:30 open config.yaml: no such file or directory
reading config
github.com/dgraph-io/dgraph/dgraph/cmd.initCmds.func1
	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:140
github.com/spf13/cobra.(*Command).preRun
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:856
github.com/spf13/cobra.(*Command).execute
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:792
github.com/spf13/cobra.(*Command).ExecuteC
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
github.com/spf13/cobra.(*Command).Execute
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/dgraph-io/dgraph/dgraph/cmd.Execute
	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:69
main.main
	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/main.go:73
runtime.main
	/usr/local/go/src/runtime/proc.go:203
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1357

github.com/dgraph-io/dgraph/x.Check
	/tmp/go/src/github.com/dgraph-io/dgraph/x/error.go:42
github.com/dgraph-io/dgraph/dgraph/cmd.initCmds.func1
	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:140
github.com/spf13/cobra.(*Command).preRun
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:856
github.com/spf13/cobra.(*Command).execute
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:792
github.com/spf13/cobra.(*Command).ExecuteC
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
github.com/spf13/cobra.(*Command).Execute
	/tmp/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/dgraph-io/dgraph/dgraph/cmd.Execute
	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:69
main.main
	/tmp/go/src/github.com/dgraph-io/dgraph/dgraph/main.go:73
runtime.main
	/usr/local/go/src/runtime/proc.go:203
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1357

Please help me in figuring out what is the correct way to do this. I have tried giving full path to the file as well, it is still reporting the same error.

Hey @praneelrathore, the dgraph zero command will look for the config.yaml file inside the container. Either you can copy the file in the container, or mount the volume which stores the config file.
The following command should work if the config.yaml is in your current working directory

docker run -it -p 5080:5080 --network dgraph_default -p 6080:6080 -v $(pwd):$(pwd) -w $(pwd) dgraph/dgraph:latest dgraph zero --config ./config.yaml

This config.yaml file is stored in my present working directory.

2 Likes

Hey @ibrahim thanks a lot for your help :slight_smile: