Dgraph DQL Tour
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 Dgraph that will serve as a sandbox for you to learn and experiment.
There are several ways to install and run Dgraph, all of which you can find in the Download page. For this tutorial, let’s run Dgraph in a container with Docker.
First, grab the latest version of Docker.
Then, pull the latest Dgraph version with:
docker pull dgraph/dgraph:latest # Note. Always use a fixed version instead of latest for production. or docker pull dgraph/standalone # Standalone makes it easy to get started. But we don't recommend it for production.
Let’s create a folder for storing Dgraph data outside of the container:
mkdir -p ~/dgraph
Now, to run Dgraph in Docker, it’s:
Choose between common Docker and Standalone.
Using Docker commands.
# Run Dgraph zero docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 \ -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph \ dgraph/dgraph:latest dgraph zero # In another terminal, now run Dgraph alpha docker exec -it dgraph dgraph alpha --cache size-mb=2048 --zero localhost:5080 --security whitelist=0.0.0.0/0
Using Docker Standalone.
docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 \ -p 9080:9080 -v ~/dgraph:/dgraph --name dgraph \ dgraph/standalone:latest
Dgraph Alpha will now be running and listening for HTTP requests on port
There are more options, but that’s all we need to get started.