Run Dgraph

Let’s run an instance of Dgraph on your machine; that’ll give you a handle on installing Dgraph and loading data yourself.

All the data in this tutorial will be stored in the instance you install and all the queries will look for Dgraph on your local machine. By running it in a container, you’ll have a fresh Drgaph that will serve as a sandbox for you to learn and experiment with.

There are a number of ways to install and run Dgraph. For this tutorial, let’s run it in a container with Docker.

First, grab the latest version of Docker.

Then, pull the latest Dgraph version with:

docker pull dgraph/dgraph

Now, to run Dgraph in Docker, it’s:

mkdir -p ~/dgraph

# Run dgraphzero
docker run -it -p 8081:8081 -p 8080:8080 -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph dgraph/dgraph dgraph zero --port_offset=-2000

# In another terminal, now run dgraph
docker exec -it dgraph dgraph server --bindall=true --memory_mb 2048 --zero localhost:5080

# Run ratel(Dgraph UI)
docker exec -it dgraph dgraph-ratel

That’s it!

Dgraph will now be running and listening on port 8080, Ratel would be running on port 8081. There are more options, but that’s all we need to get started.