# Best way to run local Dgraph executable in Docker

**URL:** <https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334>\
**Category:** Misc\
**Created:** [March 19, 2018, 10:27pm UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334 "2018-03-19T22:27:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndrewMcBurney](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/andrewmcburney/32/764_2.png) [@AndrewMcBurney](https://discuss.dgraph.io/u/AndrewMcBurney)\
**Post date:** [March 19, 2018, 10:27pm UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334/1 "2018-03-19T22:27:00Z")

</div>

Hi!

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` ([Added IP whitelist for admin/export by armcburney · Pull Request #2233 · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/pull/2233)) from an issue created recently on GitHub ([IP range whitelist for admin/export · Issue #1924 · dgraph-io/dgraph · GitHub](https://github.com/dgraph-io/dgraph/issues/1924)).

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,

Andrew

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [March 19, 2018, 10:33pm UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334/2 "2018-03-19T22:33:44Z")

</div>

There is a script at `contrib/nightly/build.sh`. 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 [https://tour.dgraph.io/intro/2/](https://tour.dgraph.io/intro/2/). 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

```auto
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

```

```auto
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.

---

<div class="post-metadata">

**Author:** ![AndrewMcBurney](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/andrewmcburney/32/764_2.png) [@AndrewMcBurney](https://discuss.dgraph.io/u/AndrewMcBurney)\
**Post date:** [March 19, 2018, 11:01pm UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334/3 "2018-03-19T23:01:12Z")

</div>

Hi Pawan,

I tried to run the `contrib/nightly/build.sh`, but ran into the problem:

```bash
./contrib/nightly/build.sh: line 61: pushd: /Users/andrew.mcburney/go/src/github.com/dgraph-io/ratel: No such file or
 directory 

```

I searched for `github.com/dgraph-io/ratel`, but was unable to find the repository on the dgraph organization. Is it a private repository?

All the best,  
Andrew

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [March 19, 2018, 11:12pm UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334/4 "2018-03-19T23:12:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AndrewMcBurney](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/andrewmcburney/32/764_2.png) [@AndrewMcBurney](https://discuss.dgraph.io/u/AndrewMcBurney)\
**Post date:** [April 9, 2018, 2:56pm UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334/5 "2018-04-09T14:56:42Z")

</div>

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:

1. 

**Input**

```bash
# ~/go/src/github.com/dgraph-io/dgraph
./contrib/nightly/build.sh

```

**Output**

> ```bash
> dgraph git/whitelist*
> ❯ ./contrib/nightly/build.sh
> ~/go/src/github.com/dgraph-io/dgraph/dgraph ~/go/src/github.com/dgraph-io/dgraph
> Building dgraph binary for darwin
> # github.com/dgraph-io/dgraph/dgraph
> 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
> ~/go/src/github.com/dgraph-io/dgraph
> 
> 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 <contact@dgraph.io>
> ---> 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
> 
> ```

1. 

```bash
cd && mkdir dgraph

```

1. 

**Input**

```bash
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

```

**Output**

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

```

1. 

**Input**

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

```

**Output**

```bash
Error: No such container: dgraph

```

* * *

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

[1]

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

```

[2]

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

```

* * *

Any help would be greatly appreciated! Thank you!

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [April 10, 2018, 7:46am UTC](https://discuss.dgraph.io/t/best-way-to-run-local-dgraph-executable-in-docker/2334/6 "2018-04-10T07:46:02Z")

</div>

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.
