Single Host Setup
We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.
To learn about Dgraph and the components, you can install and run Dgraph cluster on a single host using Docker, Docker Compose, or Dgraph command line.
Dgraph cluster can be setup running as containers on a single host.
Before you begin
Ensure that you have installed:
Launch a Dgraph standalone cluster using Docker
-
Select a name
<CONTAINER_NAME>
for you Docker container and create a directory<GRAPH_DATA_PATH>
that for Dgraph data on your local file system. -
Run a container with the dgraph/standalone image:
-
Optionally launch Ratel using the
dgraph/ratel
docker image:You can now use Ratel UI on your browser at localhost:8000 and connect to you Dgraph cluster at localhost:8080
Setup a Dgraph cluster on a single host using Docker
-
Get the
<IP_ADDRESS>
of the host using: -
Pull the latest Dgraph image using docker:
-
Verify that the image is downloaded:
-
Create a
<DGRAPH_NETWORK>
using: -
Create a directory
<ZERO_DATA>
to store data for Dgraph Zero and run the container: -
Create a directory
<ALPHA_DATA_1>
to store for Dgraph Alpha and run the container: -
Create a directory
<ALPHA_DATA_2>
to store for the second Dgraph Alpha and run the container:To override the default ports for the second Alpha use
-o
. -
Connect the Dgraph cluster that are running using https://play.dgraph.io/. For information about connecting, see Ratel UI.
Dgraph cluster can be setup running as containers on a single host.
Before you begin
Ensure that you have installed:
Launch a Dgraph standalone cluster using Docker
-
Select a name
<CONTAINER_NAME>
for you Docker container and create a directory<GRAPH_DATA_PATH>
that for Dgraph data on your local file system. -
Run a container with the dgraph/standalone image:
-
Optionally launch Ratel using the
dgraph/ratel
docker image:You can now use Ratel UI on your browser at localhost:8000 and connect to you Dgraph cluster at localhost:8080
Setup a Dgraph cluster on a single host using Docker
-
Get the
<IP_ADDRESS>
of the host using: -
Pull the latest Dgraph image using docker:
-
Verify that the image is downloaded:
-
Create a
<DGRAPH_NETWORK>
using: -
Create a directory
<ZERO_DATA>
to store data for Dgraph Zero and run the container: -
Create a directory
<ALPHA_DATA_1>
to store for Dgraph Alpha and run the container: -
Create a directory
<ALPHA_DATA_2>
to store for the second Dgraph Alpha and run the container:To override the default ports for the second Alpha use
-o
. -
Connect the Dgraph cluster that are running using https://play.dgraph.io/. For information about connecting, see Ratel UI.
You can run Dgraph directly on a single Linux host.
Before you begin
Ensure that you have:
- Installed Dgraph on the Linux host.
- Made a note of the
<IP_ADDRESS>
of the host.
Using Dgraph CLI
You can start Dgraph on a single host using the dgraph command line.
-
Run Dgraph Zero
The
--my
flag is the connection that Dgraph alphas dial to talk to Zero. So, the port5080
and the IP address must be visible to all the Dgraph alphas. For all other various flags, rundgraph zero --help
. -
Run two Dgraph Alpha nodea:
Dgraph Alpha nodes use two directories to persist data and WAL logs, and these directories must be different for each Alpha if they’re running on the same host. You can use
-p
and-w
to change the location of the data and WAL directories.To learn more about other flags, rundgraph alpha --help
. -
Connect the Dgraph cluster that are running using https://play.dgraph.io/. For information about connecting, see Ratel UI.
You can install Dgraph using the Docker Compose on a system hosted on any of the cloud provider.
Before you begin
- Ensure that you have installed Docker Compose.
- IP address of the system on cloud
<CLOUD_IP_ADDRESS>
. - IP address of the local host
<IP_ADDRESS>
.
Using Docker Compose
-
Download the Dgraph
docker-compose.yml
file:By default only the localhost IP 127.0.0.1 is allowed. When you run Dgraph on Docker, the containers are assigned IPs and those IPs need to be added to the allowed list.
-
Add a list of IPs allowed for Dgraph so that you can create the schema. Use an editor of your choice and add the
<IP_ADDRESS>
of the local host indocker-compose.yml
file: -
Run the
docker-compose
command to start the Dgraph services in the docker container:After Dgraph is installed on Docker, you can view the images and the containers running in Docker for Dgraph.
-
View the containers running for Dgraph using:
An output similar to the following appears:
-
To access the Ratel UI for queries, mutations, and altering schema, open your web browser and navigate to
http://<CLOUD_IP_ADDRESS>:8000
. -
Click Launch Latest to access the latest stable release of Ratel UI.
-
In the Dgraph Server Connection dialog that set the Dgraph server URL as
http://<CLOUD_IP_ADDRESS>:8080
-
Click Connect . The connection health appears green.
-
Click Continue to query or run mutations.
Was this page helpful?