Is there a way to restart dgraph using docker without having to delete the container and retype the run command?

I setup dgraph using docker and I’m able to get it running fine, but when I stop the dgraph container and restart it I end up not being able to restart the database. My solution has been to simply remove the container and rerun the docker run command on the dgraph docs, but if there is an easier way to restart the database I’d be very interested in knowing how.

Hey @thandy1212

Assuming you followed the commands on the docs to start dgraphzero and dgraph and then stopped both. You can restart a stopped container by using docker start instead of docker run.

Running docker ps -a, would show that a container with name dgraph already exists.

➜  dgraph git:(pawan/fix-1642) docker ps -a     
CONTAINER ID        IMAGE               COMMAND              CREATED              STATUS                      PORTS               NAMES
2db9b6c314bc        dgraph/dgraph       "dgraphzero -w zw"   About a minute ago   Exited (0) 35 seconds ago                       dgraph

You can also see the default command is the one you ran the container initially with.

Now you can run to run the dgraph container with the default command. This would run dgraphzero.

docker start -i dgraph


Setting up listener at: localhost:8888
Setting up listener at: localhost:8889
2017/10/30 02:29:01 node.go:234: Found hardstate: {Term:3 Vote:1 Commit:19 XXX_unrecognized:[]}
2017/10/30 02:29:01 node.go:246: Group 0 found 19 entries
2017/10/30 02:29:01 raft.go:292: Restarting node for dgraphzero
2017/10/30 02:29:01 raft.go:567: INFO: 1 became follower at term 3
2017/10/30 02:29:01 raft.go:315: INFO: newRaft 1 [peers: [], term: 3, commit: 19, applied: 0, lastindex: 19, lastterm: 3]
Running Dgraph zero...

Running dgraph now is same as before.

docker exec -it dgraph dgraph --bindall=true --memory_mb 2048 -peer


Dgraph version   : v0.8.3
Commit SHA-1     : 66de73f1
Commit timestamp : 2017-10-26 14:38:03 +1100
Branch           : HEAD

2017/10/30 02:30:35 pool.go:104: == CONNECT ==> Setting
2017/10/30 02:30:35 worker.go:105: Worker listening at address: [::]:12345
2017/10/30 02:30:35 gRPC server started.  Listening on port 9080
2017/10/30 02:30:35 HTTP server started.  Listening on port 8080
2017/10/30 02:30:35 groups.go:117: Connected to group zero. State: counter:22 groups:<key:1 value:<members:<key:1 value:<id:1 group_id:1 addr:"localhost:12345" leader:true last_update:1509319921 > > tablets:<key:"_predicate_" value:<group_id:1 predicate:"_predicate_" > > tablets:<key:"age" value:<group_id:1 predicate:"age" > > tablets:<key:"" value:<group_id:1 predicate:"" > > tablets:<key:"friend" value:<group_id:1 predicate:"friend" > > tablets:<key:"genre" value:<group_id:1 predicate:"genre" > > tablets:<key:"initial_release_date" value:<group_id:1 predicate:"initial_release_date" > > tablets:<key:"name" value:<group_id:1 predicate:"name" > > tablets:<key:"owns_pet" value:<group_id:1 predicate:"owns_pet" > > tablets:<key:"starring" value:<group_id:1 predicate:"starring" > > > > zeros:<key:1 value:<id:1 addr:"localhost:8888" leader:true > > maxLeaseId:10000 
2017/10/30 02:30:35 draft.go:143: Node ID: 1 with GroupID: 1
2017/10/30 02:30:35 pool.go:104: == CONNECT ==> Setting localhost:8888
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.