# Loading schema/data into Dgraph (running in docker) from file (in Windows folder), automatically

**URL:** <https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123>\
**Category:** Dgraph\
**Created:** [June 10, 2020, 8:15pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123 "2020-06-10T20:15:28Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 10, 2020, 8:15pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/1 "2020-06-10T20:15:28Z")

</div>

Hi,

I don’t know if this is a Docker issue, Windows issue, or me being a newb issue. Maybe all, or maybe none (though probably the last one). Believe me please, I have read, and re-read, the deploy docs.

I’ve first tried running the “getting started” comand in cmd prompt:

> docker run --rm -it -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph dgraph/standalone:v20.03.0

Then in the Docker dashboard, I open a CLI window and try to give the following kinds of commands (for example):

> dgraph live -s ./toy\_schema  
> dgraph live -s C:\Users\user1\subfolder\toy\_schema  
> dgraph live -s \<C:\Users\user1\subfolder\toy\_schema\>  
> dgraph live -s c:/Users/user1/subfolder/toy\_schema

These all fail. The cmd prompt is open to the folder where the schema file is, that’s why I tried first one, but it says “file or folder not found”. The second one, the Docker CLI makes the " \ " disappear, so that doesn’t work. And then it doesn’t like the \<\>. The last one, it just says “file or folder not found” again.

If I use the docker-compose.yml file instead, and run:

> docker-compose up

in the cmd prompt, then again open the CLI window and run those commands, they all fail because of

> Running transaction with dgraph endpoint: 127.0.0.1:9080  
> While trying to setup connection: context deadline exceeded. Retrying…

If it’s possible for either of these to work (hopefully I’m just doing something wrong), extension question: can this all be done automatically from one cmd prompt command, like say, adding something to the docker-compose.yml, that can execute the docker live command, or from a single cmd prompt command (I did see docker run can use /bin/bash -c to put together multiple dgraph commands) ??

EDIT: and yes I did share the C: drive, in Docker settings-\>resources-\>file sharing.

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 10, 2020, 8:50pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/2 "2020-06-10T20:50:38Z")

</div>

Now I have added the following to docker-compose.yml under volumes for zero and alpha:

> c:/Users/user1/subfolder:/data

I think that will fix the find file problem. Now my command in the Docker CLI window is:

> dgraph live -s data/toy\_schema -a localhost:9080 -z localhost:5080

And I am selecting the CLI on the zero service from the Docker dashboard. It still gives the error of:

> Running transaction with dgraph endpoint: localhost:9080  
> While trying to setup connection: context deadline exceeded. Retrying…  
> 2020/06/10 20:47:27 Could not setup connection after 1 retries

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 10, 2020, 8:52pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/3 "2020-06-10T20:52:33Z")

</div>

Could we see your `docker.compose.yaml` file.  
Are you running dgraph live in a container, or from Windows PowerShell or command shell?

Your Windows environment is Windows 10 Pro + Docker-for-Desktop?

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 10, 2020, 8:56pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/4 "2020-06-10T20:56:31Z")

</div>

> version: “3.2”  
> services:  
> zero:  
> image: dgraph/dgraph:latest  
> volumes:  
> - /tmp/data:/dgraph  
> - c:/Users/user1/subfolder:/data  
> ports:  
> - 5080:5080  
> - 6080:6080  
> restart: on-failure  
> command: dgraph zero --my=zero:5080  
> alpha:  
> image: dgraph/dgraph:latest  
> volumes:  
> - /tmp/data:/dgraph  
> - c:/Users/user1/subfolder:/data  
> ports:  
> - 8080:8080  
> - 9080:9080  
> restart: on-failure  
> command: dgraph alpha --my=alpha:7080 --lru\_mb=2048 --zero=zero:5080  
> ratel:  
> image: dgraph/dgraph:latest  
> ports:  
> - 8000:8000  
> command: dgraph-ratel

Windows 10 Enterprise + Docker Desktop (for Windows) 2.3.0.3

the dgraph live commands are in a command-line window that pops up after I click on the “CLI” button in the Docker dashboard for “zero\_1”. I assume that has to be done, I don’t think I can open a new cmd prompt and do it, because that wouldn’t be inside the container?

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 11, 2020, 9:04am UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/5 "2020-06-11T09:04:53Z")

</div>

With Docker-for-Desktop, you can use PowerShell and run the docker command and docker-compose. Docker-for-Desktop will create a VM running Linux, which has the docker service running inside the VM. It does some networking magic to make it seem as if docker is running on localhost, so that port mapping `8080:8080` will work from the Windows host, even those it is actually from the container running on the Hyper-V VM.

I think the formatting got ruined for the docker-compose.yaml as the indentation is not correct. One thing I can spot is that `/tmp/data` will not work, because Windows doesn’t have a `/tmp`.

I could suggest using relative paths, for example, in PowerShell:

```auto
mkdir Directory $home/dgraph_project
cd $home/dgraph_project
mkdir data

```

Then, in that directory, you can mount a local directory of `./data`. Using your docker-compose, but changing the volume path, you could use this one.

```auto
version: "3.2"
services:
  zero:
    image: dgraph/dgraph:latest
    ports:
    - 5080:5080
    - 6080:6080
    volumes:
    - "./data:/data"
    command: dgraph zero --my=zero:5080
  alpha:
    image: dgraph/dgraph:latest
    ports:
    - 8080:8080
    - 9080:9080
    volumes:
    - "./data:/data"
    command: dgraph alpha --my=alpha:7080 --lru_mb=2048 --zero=zero:5080
  ratel:
    image: dgraph/dgraph:latest
    ports:
    - 8000:8000
    command: dgraph-ratel

```

In PowerShell, assuming your current path is `$home/dgraph_project` with a `docker-compose.yaml` in that directory, you can bring this up with

```auto
docker-compose up -d

```

You can test the cluster health through alpha with:

- [http://localhost:8080/health](http://localhost:8080/health)
- [http://localhost:8080/state](http://localhost:8080/state)

Ratel should be working from:

- [http://localhost:8000](http://localhost:8000)

And also check if GRPC is working through 9080 with this:

```bash
dgraph increment --alpha localhost:9080

```

See if this works. Once we have healthy cluster, we can try other things.

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 11, 2020, 3:26pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/6 "2020-06-11T15:26:13Z")

</div>

Thanks for the comments and help @joaquin !!

- I was just trying to use the yml file at the link given in the Dgraph docs for Deloy ([https://dgraph.io/docs/deploy/#run-using-docker-compose-on-single-aws-instance](https://dgraph.io/docs/deploy/#run-using-docker-compose-on-single-aws-instance))  
perhaps this is assumed to be used in Linux. There doesn’t seem to be any instruction on modificaitons or otherwise using this in Windows.
- yes the indentation got squashed somehow when I pasted it into my previous reply, but it was there
- I created “dgraph\_data” dir in the folder with the docker-compose.yml, and updated to your code above except changing “./data:/data” to “./dgraph\_data:/data”
- running the following in Powershell works fine, starts that container in Docker:

> docker-compose up -d

- all of the localhost:8080 and localhost:8000 links work fine (although Ratal reports that v20.03.3 is “Health, Dgraph upgrade available” with a yellow dot, instead of green)
- however, the Powershell is then **not** capable of running your dgraph command, with the error

> dgraph : The term ‘dgraph’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

- if I instead click the CLI button on the Docker (sub-)container for alpha\_1, I can run that command just fine, and it says

> # dgraph increment --alpha localhost:9080  
> [Decoder]: Using assembly version of decoder
> 
> Running transaction with dgraph endpoint: localhost:9080  
> 0611 03:03:49.066 Counter VAL: 2 [Ts: 20] Latency: Q 4ms M 5ms S 9ms C 10ms D 1ms  
> Total: 12ms

- but if I put my schema and data files in the “dgraph\_data” folder (so they’re mounted into /data by the compose yml), still the same errors persist:

> # dgraph live -s data/toy\_schema -a localhost:9080 -z localhost:5080  
> [Decoder]: Using assembly version of decoder  
> I0611 15:06:28.986022 57 init.go:99]
> 
> Dgraph version : v20.03.3  
> Dgraph SHA-256 : 08424035910be6b6720570427948bab8352a0b5a6d59a0d20c3ec5ed29533121  
> Commit SHA-1 : fa3c19120  
> Commit timestamp : 2020-06-02 16:47:25 -0700  
> Branch : HEAD  
> Go version : go1.14.1
> 
> For Dgraph official documentation, visit [https://docs.dgraph.io](https://docs.dgraph.io).  
> For discussions about Dgraph , visit [http://discuss.hypermode.com](http://discuss.hypermode.com).  
> To say hi to the community , visit [https://dgraph.slack.com](https://dgraph.slack.com).
> 
> Licensed variously under the Apache Public License 2.0 and Dgraph Community License.  
> Copyright 2015-2020 Dgraph Labs, Inc.
> 
> Running transaction with dgraph endpoint: localhost:9080  
> 2020/06/11 15:06:38 context deadline exceeded  
> Unable to connect to zero, Is it running at localhost:5080?  
> [github.com/dgraph-io/dgraph/x.Checkf](http://github.com/dgraph-io/dgraph/x.Checkf)  
> /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:51  
> [github.com/dgraph-io/dgraph/dgraph/cmd/live.setup](http://github.com/dgraph-io/dgraph/dgraph/cmd/live.setup)  
> /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/run.go:383  
> [github.com/dgraph-io/dgraph/dgraph/cmd/live.run](http://github.com/dgraph-io/dgraph/dgraph/cmd/live.run)  
> /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/run.go:443  
> [github.com/dgraph-io/dgraph/dgraph/cmd/live.init.0.func1](http://github.com/dgraph-io/dgraph/dgraph/cmd/live.init.0.func1)  
> /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/run.go:120  
> [github.com/spf13/cobra.(\*Command).execute](http://github.com/spf13/cobra.(*Command).execute)  
> /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830  
> [github.com/spf13/cobra.(\*Command).ExecuteC](http://github.com/spf13/cobra.(*Command).ExecuteC)  
> /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914  
> [github.com/spf13/cobra.(\*Command).Execute](http://github.com/spf13/cobra.(*Command).Execute)  
> /go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864  
> [github.com/dgraph-io/dgraph/dgraph/cmd.Execute](http://github.com/dgraph-io/dgraph/dgraph/cmd.Execute)  
> /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/root.go:70  
> main.main  
> /ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/main.go:78  
> runtime.main  
> /usr/local/go/src/runtime/proc.go:203  
> runtime.goexit  
> /usr/local/go/src/runtime/asm\_amd64.s:1373

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 11, 2020, 3:44pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/7 "2020-06-11T15:44:14Z")

</div>

And what I mean by “sub-containers” is this, from the Docker Dashboard:

 ![](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/2/267adfddf255e84a51f0665ed4013c141e263e86.png)

each of those (alpha\_1,zero\_1,ratel\_1) has its own button for CLI, that can bring up a separate shell window, with sometimes different behaviors on commands.

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 11, 2020, 8:39pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/8 "2020-06-11T20:39:52Z")

</div>

On the documentation, you are correct, the docs are definitely oriented toward a POSIX oriented shell like bash or zsh (such as macOS or Linux). I think we can improve in as much as possible make it more cross-platform.

**Dgraph on Windows host** : If you want to run dgraph cli from the Windows host, you can use download it from: [Downloads | Dgraph](https://dgraph.io/downloads#download-windows)

**Dgraph from Docker container** : If you use dgraph cli from the docker container, you can do something like this from powershell to enter a bash shell inside the container:

```auto
# get current directory name (docker compose uses this in naming containers)
$cwd = "$(Split-Path -Path $(Get-Location) -Leaf)"
# login container managed by docker compose
docker exec -ti ${cwd}_alpha_1 bash

```

This might be the same thing as how you got there through the Docker-for-Desktop UI. I’m trying this out with docker-machine on _Windows 10 Home_, which doesn’t have Hyper-V.

The toy\_schema, is this something available online, or something you created? Usually for the schema, I would upload both schema and data, not just the schema.

For example, inside the alpha container:

```bash
PREFIX=https://github.com/dgraph-io/benchmarks/raw/master/data/
curl --silent --location --remote-name $PREFIX/21million.schema
curl --silent --location --remote-name $PREFIX/21million.rdf.gz
dgraph live \
 -f 21million.rdf.gz \
 -s 21million.schema \
 -a alpha:9080 \
 -z zero:5080

```

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 11, 2020, 9:23pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/9 "2020-06-11T21:23:55Z")

</div>

Hi again @joaquin ,

They’re just small examples I made up, to see if I could get loading schema/data from file.

toy\_schema:

> type Person {  
> name  
> age  
> friend  
> owns\_pet  
> owns\_vehicle  
> }
> 
> type Dog {  
> name  
> breed  
> }
> 
> type Cat {  
> name  
> breed  
> }
> 
> type Car {  
> name  
> make  
> }
> 
> name: string @index(term) .  
> age: int .  
> friend: [uid] .  
> owns\_pet: [uid] .  
> owns\_vehicle: [uid] .  
> breed: string .  
> make: string .

toy\_data:

> {  
> set {  
> \_:michael “Michael” .  
> \_:michael \<dgraph.type\> “Person” .  
> \_:michael “39” .  
> \_:michael \<owns\_pet\> \_:bark .  
> \_:michael \_:luke .
> 
> ```
> _:luke <name> "Luke" .
> _:luke <dgraph.type> "Person" .
> _:luke <age> "77" .
> _:luke <owns_pet> _:meow .
> _:luke <friend> _:Michael .
> 
> _:bark <name> "Bark" .
> _:bark <dgraph.type> "Dog" .
> _:bark <breed> "Great Dane" .
> 
> _:meow <name> "Meow" .
> _:meow <dgraph.type> "Cat" .
> _:meow <breed> "Siamese" .
> 
> ```
> 
> }  
> }

I’ve tried it both ways, and the different errors still persist.

If I go with the single command line (the “standalone”), then when I do the CLI shell from Docker, it says it can’t find the file.

in Powershell (doesn’t matter if I use “” around the volume path, results are the same):

> docker run --rm -it -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ./dgraph\_data:/data dgraph/standalone:v20.03.0

in Docker CLI (there is only a single container, in this version):

> # dgraph live -f dgraph\_data/toy\_data.rdf -s dgraph\_data/toy\_schema.schema -a localhost:9080 -z localhost:5080  
> [Decoder]: Using assembly version of decoder  
> I0611 21:22:40.070467 75 init.go:99]
> 
> Dgraph version : v20.03.0  
> Dgraph SHA-256 : 07e63901be984bd20a3505a2ee5840bb8fc4f72cc7749c485f9f77db15b9b75a  
> Commit SHA-1 : 147c8df9  
> Commit timestamp : 2020-03-30 17:28:31 -0700  
> Branch : HEAD  
> Go version : go1.14.1
> 
> For Dgraph official documentation, visit [https://docs.dgraph.io](https://docs.dgraph.io).  
> For discussions about Dgraph , visit [http://discuss.hypermode.com](http://discuss.hypermode.com).  
> To say hi to the community , visit [https://dgraph.slack.com](https://dgraph.slack.com).
> 
> Licensed variously under the Apache Public License 2.0 and Dgraph Community License.  
> Copyright 2015-2020 Dgraph Labs, Inc.
> 
> Running transaction with dgraph endpoint: localhost:9080
> 
> Processing schema file “dgraph\_data/toy\_schema.schema”  
> 2020/06/11 21:22:40 open dgraph\_data/toy\_schema.schema: no such file or directory

If I do it from docker-compose, the error still persists the same when using the above dgraph live command (with both data and schema defined).

I think we would prefer to use the docker-compose, if possible. What is the “standalone” version, and why does it only show one container in Docker? In any case, neither seem to work.

EDIT: for the standalone version, I try every variation of the command, with just using data/toy … or just using the rdf file, etc. It always says it can’t find the file.

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 11, 2020, 11:34pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/10 "2020-06-11T23:34:23Z")

</div>

I wanted to answer the _ **standalone** _ vs. _ **docker-compose** _ (get to other questions later). Standalone was meant to be a one-liner simple way to run dgraph with `docker run`, and not meant for production.

For example:

```bash
docker run --rm -it -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ./dgraph_data:/dgraph dgraph/standalone:latest

```

Personally, I prefer having multiple containers with `docker-compose` as this is closer to a eventual production environment. It also helps you learn the various components, their roles, ports, etc.

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 12, 2020, 8:02am UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/11 "2020-06-12T08:02:25Z")

</div>

On live loader. I notice a few that would cause a problems:

- **toy\_data** : missing type for `<name>` and `<age>` in first node
- **toy\_data** : smart quotes ` “”` instead of ASCII quotes `"`. Maybe copy/paste error.
- **toy\_data** and **toy\_schema** : CR/LF - I don’t think this would cause a problem, but just in case, converted it to LF.

The schema needs to be in **RDF** or **JSON** format for live loader. I converted your data from the **`GraphQL+-`** from to **JSON** format and then tested it with live loader.

Thus once you are log into the system with `docker exec -ti $container_name bash`, you would want to run something like:

```bash
## create schema file
cat <<-EOF > toy_schema
type Person {
  name
  age
  friend
  owns_pet
  owns_vehicle
}

type Dog {
  name
  breed
}

type Cat {
  name
  breed
}

type Car {
  name
  make
}

name: string @index(term) .
age: int .
friend: [uid] .
owns_pet: [uid] .
owns_vehicle: [uid] .
breed: string .
make: string .
EOF

## create data file in JSON format
cat <<-EOF > toy_data.json
{
  "set": [
    {
      "uid": "_:michael",
      "dgraph.type": "Person",
      "name": "Michael",
      "age": "39",
      "owns_pet": { "uid": "_:bark" },
      "friend": { "uid": "_:luke" }
    },
    {
      "uid": "_:luke",
      "dgraph.type": "Person",
      "name": "Luke",
      "age": "77",
      "owns_pet": { "uid": "_:meow" }
    },
    {
      "uid": "_:bark",
      "dgraph.type": "Dog",
      "name": "Bark",
      "breed": "Great Dane"
    },
    {
      "uid": "_:meow",
      "dgraph.type": "Cat",
      "name": "Meow",
      "breed": "Siamese"
    }
  ]
}
EOF

## use live loader
dgraph live -f toy_data.json -s toy_schema -a alpha:9080 -z zero:5080

```

Afterwards, I can run a query in **Ratel** :

```graphql
{
  pets_friends(func: eq(name, "Michael")) {
    name
    age
    owns_pet {
      breed 
    }
    friend {
      name
      owns_pet {
        breed
      }
    }
  }
}

```

This will show something like this:

![ratel_snippet](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/a/ac0d9574d6e2af2bb3596a7c8a1c733747c7f72c.png)

I also tried this out by loading the schema in the original format with corrections on a clean system (`docker-compose stop; docker-compose rm; docker-compose up -d`), and it got the same results.

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 12, 2020, 3:25pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/12 "2020-06-12T15:25:22Z")

</div>

Thanks again @joaquin for the continued great support !!

- agree that we prefer to use the docker-compose file over the standalone command

- the pasting from sublime (or maybe it is the blockcode function in the reply window) is stripping out/changing things that it shouldn’t be. I will just post screenshots, to avoid confusion.

- docker-compose.yml (change to ./dgraph\_data:/dgraph , as you had it above)  
 ![](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/b/b836425d9c15121c2e9b0be5147efcf1ec94cbf9.png)

- toy\_schema ( **note** : I think there is some confusion here? My understanding is Dgraph must use graphQL± language for schema, and it does not appear you made any changes to this file?  

- toy\_data.rdf  
 ![](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/a/a27dbc0bf034dc8c19242694effbd03aacd20976.png)

- toy\_data.json (this one, you converted from rdf to json, which I took as you have it above)  

- with the schema/data files mounted (rather than using cat), and then using the docker exec command and your version of dgraph live command above, _it works with the json file !_ Maybe in the live command, it was important to use alpha: and zero: instead of localhost: ? And/or , maybe the files needed to mount to /dgraph instead of /data ? I’m not sure which things did the trick  

- but when doing with the rdf file, there is error  

- our actual data files are already in rdf format, and we prefer not to convert them to json if possible

- lastly, is there any way you know of to embed these commands into the docker-compose file, so everything loads up on a new machine (with Docker installed) with a single command? If not, we can probably create a script file

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 12, 2020, 4:16pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/13 "2020-06-12T16:16:39Z")

</div>

- **text editor** : I use [atom.io](http://atom.io) for text editor (but also [vs code](https://code.visualstudio.com/) is good too). Atom perserves just pure text, where other adds formatting. Sublime used to be my favorite.
- **loading schema/data** :
  - loading directly if you have `dgraph` cli client installed on the host will work.
  - using a mounted disk didn’t work for me, at least with Docker Machine (Virtualbox) on Win10 Home.
  - `docker cp` to copy from host to container should also work.

- **RDF vs JSON** - When I was testing this, I RDF where uids are autogenerated, I could not get it to work with live loader

```auto
{ set { 
   _:michael <name> "Michael" .
   _:michael <dgraph.type> "Person"
   _:luke <name> "Luke" . 
 } 
}

```

The RDF with uids manually specified should work fine

```auto
<0x1> <name> "Michael" .
<0x1> <dgraph.type> "Person" . 
<0x2> <name> "Luke" .

```

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 12, 2020, 4:30pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/14 "2020-06-12T16:30:57Z")

</div>

Hi @joaquin, thanks I will try atom.

- our actual (big) data file is rdf with uids autogenerated, and we would prefer not to rewrite it if possible
- no issue mounting, for me, it worked fine. dgraph live found the toy\_data.rdf file no problem
- the problem was there was some error with dgraph live to load the data file, in that format

Can you suggest and give example of if there is another way to load the (already mounted) rdf (auto) data file ?

EDIT: if I manually copy and paste the rdf (auto uid) code into the “Mutation” in Ratel, it works fine. So there must be a way that this can be loaded from file??

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 12, 2020, 8:04pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/15 "2020-06-12T20:04:09Z")

</div>

I found out that the `{ set { RDF } }` is only needed for sending this over HTTP(S). If just have only the n-quads themselves, it should work, e.g.

```auto
_:bark <name> "Bark" .
_:bark <dgraph.type> "Dog" .
_:bark <breed> "Great Dane" .

```

I will try this out later when I get a chance.

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 12, 2020, 8:58pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/16 "2020-06-12T20:58:56Z")

</div>

Yes @joaquin that works !

Thanks for all your support !!

---

<div class="post-metadata">

**Author:** ![leka0024](https://avatars.discourse-cdn.com/v4/letter/l/aeb1de/32.png) [@leka0024](https://discuss.dgraph.io/u/leka0024)\
**Post date:** [June 12, 2020, 9:13pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/17 "2020-06-12T21:13:19Z")

</div>

One last question @joaquin (please let me know if needs a new thread):

Even if I run `docker-compose stop; docker-compose rm` and then run the dgraph live command on a new `docker-compose up -d` setup … it’s like the data got “doubled”. There are now twice as many edges & nodes as should be. How can the data persist like that? And anyway, is there a dgraph command I can run (in the container … zero? alpha?) to delete the old data before updating the new?

Thank you!

EDIT: I think I solved this one myself, according to [https://dgraph.io/docs/deploy/#deleting-database](https://dgraph.io/docs/deploy/#deleting-database) you can simply delete the folders “p”, “w” (and I also had one called “zw”), in the same Windows directory as the schema and data.rdf files.

---

<div class="post-metadata">

**Author:** ![joaquin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/joaquin/32/2619_2.png) [@joaquin](https://discuss.dgraph.io/u/joaquin)\
**Post date:** [June 12, 2020, 10:05pm UTC](https://discuss.dgraph.io/t/loading-schema-data-into-dgraph-running-in-docker-from-file-in-windows-folder-automatically/7123/18 "2020-06-12T22:05:53Z")

</div>

That is because you have mounted directory on local disk, so that data persists between destroying the in-memory running container. You would need to purge the data files as well to get a clean new environment. When you load the data twice, you get new set of nodes.

Also I did try just the pure RDF as toy\_data.rdf and it work as expected with live loader:

```bash
dgraph live -f toy_data.rdf -s toy.schema -a alpha:9080 -z zero:5080

```

The RDF:

```auto
_:michael <name> "Michael" .
_:michael <dgraph.type> "Person" .
_:michael <age> "39" .
_:michael <owns_pet> _:bark .
_:michael <friend> _:luke .

_:luke <name> "Luke" .
_:luke <dgraph.type> "Person" .
_:luke <age> "77" .
_:luke <owns_pet> _:meow .
_:luke <friend> _:Michael .

_:bark <name> "Bark" .
_:bark <dgraph.type> "Dog" .
_:bark <breed> "Great Dane" .

_:meow <name> "Meow" .
_:meow <dgraph.type> "Cat" .
_:meow <breed> "Siamese" .

```
