Best way to run local Dgraph executable in Docker


I’m new to Go, Dgraph, and Docker, so this may be a bit of a silly question (I apologize in advance).

I created a PR to add a whitelist feature on admin/export ( from an issue created recently on GitHub (

I’m not certain what the best way to test this feature is. Pawan suggested that Docker would be a good approach, but I’m not sure what it would entail testing this in Docker using my local executable.

Any advice would be greatly appreciated. Again, I apologize if this is a silly question.

All the best,


There is a script at contrib/nightly/ When you run that, it builds the binary and embeds it in a docker image with tag master. Then you can use it to run dgraph by following the instructions at The only difference being that you would use the master tag. Also, you don’t need to pull the image, as you already have it locally.

So first instruction becomes

docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph dgraph/dgraph:master dgraph zero
docker exec -it dgraph dgraph server --memory_mb 2048 --zero localhost:5080

Now if you try to run export from outside the Docker container running zero and server (i.e. from your host machine), you should get an error.

Hi Pawan,

I tried to run the contrib/nightly/, but ran into the problem:

./contrib/nightly/ line 61: pushd: /Users/andrew.mcburney/go/src/ No such file or

I searched for, but was unable to find the repository on the dgraph organization. Is it a private repository?

All the best,

Yeah, it is a private repo. I have made the part about building Ratel optional in master. Can you pull master and try again?

Hi Pawan,

My apologies for the lack of communication. These past few weeks I was very busy, and had to put this Pull Request on hold. I’ve been having trouble building and running the container and was hoping to get some help debugging. Like I said before, I’m relatively new to docker, so I apologize if I’m missing something obvious.

I have the reproducible steps below:


# ~/go/src/


dgraph git/whitelist*
❯ ./contrib/nightly/
~/go/src/ ~/go/src/
Building dgraph binary for darwin
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in type..eqfunc.[101]interface {} from /var/folders/4p/0shw95953cd54pckwf_k_nrr0000gn/T/go-link-205319190/go.o. To fix th
is warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie

Size of files after  strip: 30M /tmp/dgraph-build

Creating tar file
a .
a ./dgraph

Size of tar file: 9.1M  dgraph-darwin-amd64.tar.gz
Sending build context to Docker daemon  308.3MB
Step 1/8 : FROM ubuntu:16.04
 ---> f975c5035748
Step 2/8 : MAINTAINER Dgraph Labs <>
 ---> Using cache
 ---> b893607b40b8
Step 3/8 : RUN mkdir /dgraph     && apt-get update     && apt-get install -y --no-install-recommends ca-certificates curl     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> d0a7fdd796cf
Step 4/8 : ADD dgraph-build /usr/local/bin
 ---> Using cache
 ---> 94e621e52f80
Step 5/8 : EXPOSE 8080
 ---> Using cache
 ---> c359f8c014f0
Step 6/8 : EXPOSE 9080
 ---> Using cache
 ---> f8c3de8da666
Step 7/8 : WORKDIR /dgraph
 ---> Using cache
 ---> 76e0a7273f3a
Step 8/8 : CMD ["dgraph"] # Shows the dgraph version and commands available.
 ---> Using cache
 ---> 45f770de0163
Successfully built 45f770de0163
Successfully tagged dgraph/dgraph:master
cd && mkdir dgraph


docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph dgraph/dgraph:master dgraph zero


standard_init_linux.go:195: exec user process caused "exec format error"


# in another terminal
docker exec -it dgraph dgraph server --memory_mb 2048 --zero localhost:5080


Error: No such container: dgraph

I also tried with [1] and [2], but it still couldn’t find the containers.


docker exec -it dgraph/dgraph:master dgraph server --memory_mb 2048 --zero localhost:5080


docker exec -it ~/dgraph:/dgraph dgraph server --memory_mb 2048 --zero localhost:5080

Any help would be greatly appreciated! Thank you!

The problem is that the binary is built for OSX but docker container is essentially running Linux and requires binaries built on Linux. You could try this on a Linux machine if you have one or we can merge your PR in and I can test it for you.

Another method is that you download the dgraph code on a virtual machine (or a docker container) and run it but I can understand that would be tricky if you are not well versed with the technology.