Seperate Dev and Test instances of DGraph

Similar to this thread

I am trying to create a test db instance on my machine in addition to the development db instance I have running. So I want the test DB spun up on a different port at the same time I have my dev db running.

This is the config I got to work, just as I was about to post this question. So I figured I would post my answer in case anyone else wants to do this.

version: "3.2"
services:
  zero-test:
    image: dgraph/dgraph:v1.0.3
    volumes:
      - type: volume
        source: dgraph-test
        target: /dgraph-test
        volume:
          nocopy: true
    ports:
      - 6081:6081
      - 5081:5081
    restart: on-failure
    command: dgraph zero --port_offset 1 --my=zero-test:5081
  server-test:
    image: dgraph/dgraph:v1.0.3
    volumes:
      - type: volume
        source: dgraph-test
        target: /dgraph-test
        volume:
          nocopy: true
    ports:
      - 8081:8081
      - 9081:9081
    restart: on-failure
    command: dgraph server --my=server-test:7081 --memory_mb=2048 --zero=zero-test:5081 -o 1

volumes:
  dgraph-test:
1 Like

Quick note

If have two docker compose files in the same directory, one test, one dev. Add a -p “project” flag to when calling docker compose up or you can get project collisions.

docker-compose -f docker-compose.dev.yml -p dgraph-dev up -d

and

docker-compose -f docker-compose.test.yml -p dgraph-test up -d

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.