Ok, so from what I understand you want to run two completely unrelated instances of Dgraph (Server and Zero) on the same machine using Docker Compose.
You can do it using the following docker-compose.yml
version: "3"
services:
zero1:
image: dgraph/dgraph:latest
volumes:
- /tmp/data1:/dgraph
ports:
- 6080:6080
restart: on-failure
command: dgraph zero --port_offset -2000 --my=zero1:5080
server1:
image: dgraph/dgraph:latest
volumes:
- /tmp/data1:/dgraph
ports:
- 8080:8080
- 9080:9080
restart: on-failure
command: dgraph server --my=server1:7080 --memory_mb=2048 --zero=zero1:5080
zero2:
image: dgraph/dgraph:latest
volumes:
- /tmp/data2:/dgraph
ports:
- 6081:6081
restart: on-failure
command: dgraph zero --port_offset -1999 --my=zero2:5081
server2:
image: dgraph/dgraph:latest
volumes:
- /tmp/data2:/dgraph
ports:
- 8081:8081
- 9081:9081
restart: on-failure
command: dgraph server --my=server2:7081 --memory_mb=2048 --zero=zero2:5081 -o 1
You can also verify that things are setup correctly and both of your single server clusters are working fine by checking
http://127.0.0.1:6080/state
and http://127.0.0.1:6081/state