Cannot set whitelist with DockerCompose Dgraph SetUp

Hi, I have set up Dgraph with docker compose according to this guide. the containers run perfectly but, when I tried to whitelist my host pc IP (then to be able to upload the schema.graphql) with the commands:

(to get inside the dgraph alpha container)
docker exec -it hello-dgraph_alpha_1 bash
(According to the guide to whitelist IPs)
dgraph alpha --whitelist 172.17.0.0:172.20.0.0,192.168.1.1

but I get the error:


[Decoder]: Using assembly version of decoder
[Sentry] 2020/09/25 02:58:05 Integration installed: ContextifyFrames
[Sentry] 2020/09/25 02:58:05 Integration installed: Environment
[Sentry] 2020/09/25 02:58:05 Integration installed: Modules
[Sentry] 2020/09/25 02:58:05 Integration installed: IgnoreErrors
[Decoder]: Using assembly version of decoder
[Sentry] 2020/09/25 02:58:05 Integration installed: ContextifyFrames
[Sentry] 2020/09/25 02:58:05 Integration installed: Environment
[Sentry] 2020/09/25 02:58:05 Integration installed: Modules
[Sentry] 2020/09/25 02:58:05 Integration installed: IgnoreErrors
I0925 02:58:05.768337     135 sentry_integration.go:48] This instance of Dgraph will send anonymous reports of panics back to Dgraph Labs via Sentry. No confidential information is sent. These reports help improve Dgraph. To opt-out, restart your instance with the --enable_sentry=false flag. For more info, see https://dgraph.io/docs/howto/#data-handling.
I0925 02:58:05.769170     135 config.go:114] LRU memory (--lru_mb) set to 2976.25MB, 25% of the total RAM found (11905MB)
For more information on --lru_mb please read https://dgraph.io/docs/deploy/#config
I0925 02:58:05.769225     135 util_ee.go:126] KeyReader instantiated of type <nil>
I0925 02:58:05.916599     135 init.go:102] 

Dgraph version   : v20.07.1
Dgraph codename  : shuri-1
Dgraph SHA-256   : 29d6804d57da4b9ddcc2173c5fe1631b97031d1b364b8b75e52cfa180ec36de6
Commit SHA-1     : d7123d93e
Commit timestamp : 2020-09-17 14:57:43 -0700
Branch           : HEAD
Go version       : go1.14.4

For Dgraph official documentation, visit https://dgraph.io/docs/.
For discussions about Dgraph     , visit http://discuss.dgraph.io.
To say hi to the community       , visit https://dgraph.slack.com.

Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2020 Dgraph Labs, Inc.


I0925 02:58:05.916628     135 run.go:714] x.Config: {PortOffset:0 QueryEdgeLimit:1000000 NormalizeNodeLimit:10000 PollInterval:1s GraphqlExtension:true}
I0925 02:58:05.916686     135 run.go:715] x.WorkerConfig: {ExportPath:export NumPendingProposals:256 Tracing:0.01 MyAddr: ZeroAddr:[localhost:5080] RaftId:0 WhiteListedIPRanges:[{Lower:172.17.0.0 Upper:172.20.0.0} {Lower:192.168.1.1 Upper:192.168.1.1}] MaxRetries:-1 StrictMutations:false AclEnabled:false AbortOlderThan:5m0s SnapshotAfter:10000 ProposedGroupId:0 StartTime:2020-09-25 02:58:05.452338678 +0000 UTC m=+0.010560026 LudicrousMode:false EncryptionKey:**** LogRequest:0}
I0925 02:58:05.916744     135 run.go:716] worker.Config: {PostingDir:p BadgerTables:mmap BadgerVlog:mmap BadgerWalTables:mmap BadgerWalVlog:mmap BadgerCompressionLevel:3 WALDir:w MutationsMode:0 AuthToken: AllottedMemory:2976.25 PBlockCacheSize:0 PIndexCacheSize:0 WBlockCacheSize:0 WIndexCacheSize:0 HmacSecret:**** AccessJwtTtl:0s RefreshJwtTtl:0s AclRefreshInterval:0s}
I0925 02:58:05.916832     135 server_state.go:78] Setting Badger Compression Level: 3
I0925 02:58:05.916844     135 server_state.go:99] Setting Badger table load option: mmap
I0925 02:58:05.916851     135 server_state.go:111] Setting Badger value log load option: mmap
I0925 02:58:05.916858     135 server_state.go:150] Opening write-ahead log BadgerDB with options: {Dir:w ValueDir:w SyncWrites:false TableLoadingMode:2 ValueLogLoadingMode:2 NumVersionsToKeep:1 ReadOnly:false Truncate:true Logger:0x2be83e8 Compression:2 InMemory:false MaxTableSize:67108864 LevelSizeMultiplier:10 MaxLevels:7 ValueThreshold:1048576 NumMemtables:5 BlockSize:4096 BloomFalsePositive:0.01 KeepL0InMemory:false BlockCacheSize:0 IndexCacheSize:0 LoadBloomsOnOpen:false NumLevelZeroTables:5 NumLevelZeroTablesStall:15 LevelOneSize:268435456 ValueLogFileSize:1073741823 ValueLogMaxEntries:10000 NumCompactors:2 CompactL0OnClose:true LogRotatesToFlush:2 ZSTDCompressionLevel:3 VerifyValueChecksum:false EncryptionKey:[] EncryptionKeyRotationDuration:240h0m0s BypassLockGuard:false ChecksumVerificationMode:0 DetectConflicts:false managedTxns:false maxBatchCount:0 maxBatchSize:0}
[Sentry] 2020/09/25 02:58:05 Sending fatal event [dbbeb43d1a7c46df82583b54ba41b353] to o318308.ingest.sentry.io project: 1805390
2020/09/25 02:58:05 resource temporarily unavailable
Cannot acquire directory lock on "w".  Another process is using this Badger database.
github.com/dgraph-io/badger/v2.acquireDirectoryLock
	/go/pkg/mod/github.com/dgraph-io/badger/v2@v2.2007.2-0.20200827131741-d5a25b83fbf4/dir_unix.go:65
github.com/dgraph-io/badger/v2.Open
	/go/pkg/mod/github.com/dgraph-io/badger/v2@v2.2007.2-0.20200827131741-d5a25b83fbf4/db.go:255
github.com/dgraph-io/dgraph/worker.(*ServerState).initStorage
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:153
github.com/dgraph-io/dgraph/worker.InitServerState
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:54
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.run
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:718
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.init.2.func1
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:97
github.com/spf13/cobra.(*Command).execute
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830
github.com/spf13/cobra.(*Command).ExecuteC
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
github.com/spf13/cobra.(*Command).Execute
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/dgraph-io/dgraph/dgraph/cmd.Execute
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:70
main.main
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/main.go:78
runtime.main
	/usr/local/go/src/runtime/proc.go:203
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1373
Error while creating badger KV WAL store
github.com/dgraph-io/dgraph/x.Checkf
	/ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:51
github.com/dgraph-io/dgraph/worker.(*ServerState).initStorage
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:154
github.com/dgraph-io/dgraph/worker.InitServerState
	/ext-go/1/src/github.com/dgraph-io/dgraph/worker/server_state.go:54
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.run
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:718
github.com/dgraph-io/dgraph/dgraph/cmd/alpha.init.2.func1
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/run.go:97
github.com/spf13/cobra.(*Command).execute
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830
github.com/spf13/cobra.(*Command).ExecuteC
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914
github.com/spf13/cobra.(*Command).Execute
	/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
github.com/dgraph-io/dgraph/dgraph/cmd.Execute
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:70
main.main
	/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/main.go:78
runtime.main
	/usr/local/go/src/runtime/proc.go:203
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1373

With this I can’t continue with the upload of the schema.graphql.

Looking the guide I tried also setting up the standalone version with docker and I can tell that with that version the --whitelist command works and I could upload the schema.graphql. But still I want to try to set the whitelist with the docker-compose version.

Any ideas or ways to set whitelist properly with the docker-compose setup version of dgraph?

Best regards

The main issue doesn’t seem to be whitelisting related. Give me a few mins to checkout what this means.

@ibrahim - thoughts?

EDIT: I noticed this in the yaml file - (but I’m a docker n00b @joaquin to double check?) :

The compose file sets -my=7080 but 7080 isn’t part of the published or target ports

alpha:
    image: dgraph/dgraph:latest
    volumes:
      - /tmp/data:/dgraph
    ports:  # I note that 7080 is not anywhere in this list of exposed ports...
      - 8080:8080
      - 9080:9080
    restart: on-failure
    command: dgraph alpha --my=alpha:7080 --lru_mb=2048 --zero=zero:5080

Also, at the top of the comments it says

# It mounts /tmp/data on the host machine to /dgraph within the
# container. You can change /tmp/data to a more appropriate location.

Which means that you might have a local Dgraph instance running on your host machine @anargu - can you please check?

Thanks for the quick response.

Yes, if I go to that local directory i can see these dirs in my /tmp/data/:
p/ w/ zw/

Do I delete them?

No.

But check you might not have other docker images running Dgraph alphas.

Use docker ps or docker-compose ps

Ok, I have no other containers of Dgraph alphas running. I checked it doing docker ps

Are you trying to initiate another instance of Dgraph alpha?

If so you might have to change your yaml file to include this

command: dgraph alpha --my=alpha:7080 --lru_mb=2048 --zero=zero:5080 --whitelist 172.17.0.0:172.20.0.0,192.168.1.1

Thanks, finally it worked.

with that config I could run again from docker-compose without problems.

Just to note, I had to modify the ending IP of the first part to 172.17.0.0:172.30.0.0 because the first try it gives me the error (just to make sure my IP was included in the whitelist rule)

{"errors":[{"message":"resolving updateGQLSchema failed because unauthorized ip address: 172.20.0.1 (Locations: [{Line: 3, Column: 4}])","extensions":{"code":"Error"}}]}

Then after that and running again the command to load schema.graphql successfully worked.

1 Like

Just curious, why didn’t work before, when I tried by entering inside the container and then executing the dgraph alpha command ?

That’s because there is a dgraph alpha already running (as specified by your docker-compose file). When you call dgraph alpha you’re trying to start a second instance of a Alpha node, with the same exact location on where to store data (/tmp/data). This caused an error.

Ok, now I understand it, thanks.