As you know I can get the node to start: docker run -v $(pwd):/dgraph -p 9000:9000 -it dgraph/standalone:graphql dgraph graphql --alpha=local_server_1:9080
But then is logs:
I1126 14:07:13.981923 1 run.go:137] Starting GraphQL with Dgraph at: local_server_1:9080
I1126 14:07:13.982904 1 run.go:169] Bringing up GraphQL HTTP API at 0.0.0.0:9000/graphql
I1126 14:07:13.982983 1 run.go:170] Bringing up GraphiQL web interface for HTTP API at 0.0.0.0:9000/graphiql
I1126 14:07:13.983025 1 run.go:171] Bringing up GraphQL HTTP admin API at 0.0.0.0:9000/admin
I1126 14:07:13.983047 1 run.go:172] Bringing up GraphiQL web interface for HTTP admin API at 0.0.0.0:9000/admin/graphiql
I1126 14:07:13.984334 1 admin.go:276] Trying to connect to Dgraph at local_server_1:9080
I1126 14:07:33.988844 1 admin.go:276] Trying to connect to Dgraph at local_server_1:9080
And then it just keeps trying. And Just to recap, I am able to connect via dgo(the docker client to ipaddress)… hmm, I will just try with the ip address.
Same thing with:
If I docker run with “–network=“host”” and use “–alpha=127.0.0.1:9080” I get a connection:
I1126 15:42:54.555586 1 run.go:137] Starting GraphQL with Dgraph at: 127.0.0.1:9080
I1126 15:42:54.556323 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
I1126 15:42:54.566899 1 run.go:169] Bringing up GraphQL HTTP API at 0.0.0.0:9000/graphql
I1126 15:42:54.567009 1 run.go:170] Bringing up GraphiQL web interface for HTTP API at 0.0.0.0:9000/graphiql
I1126 15:42:54.567038 1 run.go:171] Bringing up GraphQL HTTP admin API at 0.0.0.0:9000/admin
I1126 15:42:54.567085 1 run.go:172] Bringing up GraphiQL web interface for HTTP admin API at 0.0.0.0:9000/admin/graphiql
I1126 15:42:54.602796 1 admin.go:285] Established Dgraph connection
I1126 15:43:04.590033 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
I1126 15:43:04.599727 1 admin.go:285] Established Dgraph connection
I1126 15:43:14.605770 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
I1126 15:43:14.613432 1 admin.go:285] Established Dgraph connection
I1126 15:43:24.620181 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
I1126 15:43:24.628213 1 admin.go:285] Established Dgraph connection
I1126 15:43:34.600236 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
It keeps doing “Trying to connect” and “Established Dgraph connection” maybe it is just checking for health?
I will try with graphql_playground and get back…
But I would still expect it to be able to use local_default network?
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (7) Failed to connect to localhost port 9000: Connection refused
Connection is refused do to a warning when running docker with --network="host":
docker run --network="host" -v $(pwd):/dgraph -p 9000:9000 -it dgraph/standalone:graphql dgraph graphql --alpha=127.0.0.1:9080
WARNING: Published ports are discarded when using host network mode
I will keep trying to see if I can connect via local_default network…
Can you share how you’re running Dgraph itself? The key here is to get both Dgraph and the GraphQL API on Dgraph networked together. If you want everything to run on your host network namespace, then you can use the --network host option for docker run, don’t use -p to publish any ports, and point everything to the proper ports on localhost.
Step 1. Standard dgraph setup from: https://docs.dgraph.io/get-started/#docker-compose
I am running: docker-compose up -d
This works as expected, and is exposing / mapped from the compose file incl. port 9080.
Step 2.
Now I tried: docker run --network="host" -v $(pwd):/dgraph -it dgraph/standalone:graphql dgraph graphql --alpha=127.0.0.1:9080
And it looks like it is running:
I1126 19:08:03.829936 1 run.go:137] Starting GraphQL with Dgraph at: 127.0.0.1:9080
I1126 19:08:03.832279 1 run.go:169] Bringing up GraphQL HTTP API at 0.0.0.0:9000/graphql
I1126 19:08:03.832356 1 run.go:170] Bringing up GraphiQL web interface for HTTP API at 0.0.0.0:9000/graphiql
I1126 19:08:03.832383 1 run.go:171] Bringing up GraphQL HTTP admin API at 0.0.0.0:9000/admin
I1126 19:08:03.832406 1 run.go:172] Bringing up GraphiQL web interface for HTTP admin API at 0.0.0.0:9000/admin/graphiql
I1126 19:08:03.832868 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
I1126 19:08:03.838535 1 admin.go:285] Established Dgraph connection
I1126 19:08:13.852418 1 admin.go:276] Trying to connect to Dgraph at 127.0.0.1:9080
I1126 19:08:13.856081 1 admin.go:285] Established Dgraph connection
Step 3. The adding the schema:
jq -n --arg schema "$(cat schema.graphql)" '{ query: "mutation addSchema($sch: String!) { addSchema(input: { schema: $sch }) { schema { schema } } }", variables: { sch: $schema }}' | curl -X POST -H "Content-Type: application/json" http://localhost:9000/admin -d @- | jq -r
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (7) Failed to connect to localhost port 9000: Connection refused
You mention “Dgraph networked” - I have standard “local_default”?
This will eventually run on Kubernetes cluster, I just need to see it work on my local machine.
This error message means wherever you’re running the jq / curl command cannot reach localhost:9000. Can you confirm that localhost:9000 is accessible? The --network="host" Docker option only works on Linux, not Docker for Mac or Docker for Windows.
If you curl the /admin endpoint you should get a response back.
$ curl localhost:9000/admin
{"errors":[{"message":"no query string supplied in request"}],"extensions":{"requestID":"6f732a5e-e201-4e49-bf22-a16521fe1a68"}}%
Another thing: GraphQL API for Dgraph currently requires Dgraph version from master, not v1.1.0. The Docker Compose config you find on docs is configured to run v1.1.0, so you’ll need to change the image to the master version in your test.
Well I am running Docker for Mac I will try to see if I can get it up and running on Kubernetes - any suggestion, apart from running Dgraph version from master - git master branch right, and is there a docker container containing this?
And for local testing, maybe a docker-compose.yaml file could help trying out this scenario?
Actually, the current master Dgraph binary does not currently have the dgraph graphql subcommand. The main way to use the GraphQL API for Dgraph is with the dgraph/standalone:graphql image. Here’s a Docker Compose config for the “clustered” mode using that image. This should work on Mac too:
Fantastic, and indeed the docker-compose you send me is working.
Update: No worries, I will just try to convert you docker-compose yaml file to K8s yaml file.
Thanks again Daniel - and I can’t wait to get my hands on the release
Do you think I can get this up on Kubernetes, that will be really nice to show of?