Setting up cluster with docker-compose

What I want to do

I’m trying to setup a Dgraph cluster using docker-compose with 3x zero and 3x alpha nodes but it doesn’t work. Alphas after initial connection to Zeros trying to connect non-existing “zero:5080” address.

What I did

See the example YAML file below

version: "3.2"
services:
  zero-0:
    image: dgraph/dgraph:latest
    container_name: zero-0
    volumes:
      - /tmp/dgraph/zero-0/data:/dgraph
    ports:
      - 5080:5080
      - 6080:6080
    restart: on-failure
    command: dgraph zero --my=zero-0:5080
  zero-1:
    image: dgraph/dgraph:latest
    container_name: zero-1
    volumes:
      - /tmp/dgraph/zero-1/data:/dgraph
    ports:
      - 5081:5081
      - 6081:6081
    restart: on-failure
    command: dgraph zero --my=zero-1:5081 -o=1
  zero-2:
    image: dgraph/dgraph:latest
    container_name: zero-2
    volumes:
      - /tmp/dgraph/zero-2/data:/dgraph
    ports:
      - 5082:5082
      - 6082:6082
    restart: on-failure
    command: dgraph zero --my=zero-2:5082 -o=2
  alpha-0:
    image: dgraph/dgraph:latest
    container_name: alpha-0
    volumes:
      - /tmp/dgraph/alpha-0/data:/dgraph
    ports:
      - 7080:7080
      - 8080:8080
      - 9080:9080
    restart: on-failure
    command: dgraph alpha --zero=zero-0:5080,zero-1:5081,zero-2:5082 --my=alpha-0:7080
  alpha-1:
    image: dgraph/dgraph:latest
    container_name: alpha-1
    volumes:
      - /tmp/dgraph/alpha-1/data:/dgraph
    ports:
      - 7081:7081
      - 8081:8081
      - 9081:9081
    restart: on-failure
    command: dgraph alpha --zero=zero-0:5080,zero-1:5081,zero-2:5082 --my=alpha-1:7081 -o=1
  alpha-2:
    image: dgraph/dgraph:latest
    container_name: alpha-2
    volumes:
      - /tmp/dgraph/alpha-2/data:/dgraph
    ports:
      - 7082:7082
      - 8082:8082
      - 9082:9082
    restart: on-failure
    command: dgraph alpha --zero=zero-0:5080,zero-1:5081,zero-2:5082 --my=alpha-2:7082 -o=2
  ratel:
    image: dgraph/ratel:latest
    container_name: ratel
    ports:
      - 8000:8000
    command: dgraph-ratel

Log entries

...
alpha-1    | I0416 08:30:30.044594      17 run.go:742] gRPC server started.  Listening on port 9081
alpha-1    | I0416 08:30:30.044600      17 run.go:743] HTTP server started.  Listening on port 8081
alpha-0    | I0416 08:30:30.098042      17 pool.go:164] CONN: Connecting to zero-1:5081
zero-1     | I0416 08:30:30.101949      17 zero.go:511] Got connection request: cluster_info_only:true
zero-1     | I0416 08:30:30.102095      17 log.go:34] 1 no leader at term 29; dropping index reading msg
alpha-2    | I0416 08:30:30.121435      18 pool.go:164] CONN: Connecting to zero-0:5080
zero-0     | I0416 08:30:30.125838      16 zero.go:511] Got connection request: cluster_info_only:true
zero-0     | I0416 08:30:30.125972      16 log.go:34] 1 no leader at term 30; dropping index reading msg
alpha-1    | I0416 08:30:30.142785      17 pool.go:164] CONN: Connecting to zero-0:5080
...
zero-1     | I0416 08:30:34.103349      17 zero.go:536] Connected: cluster_info_only:true
alpha-0    | I0416 08:30:34.104111      17 pool.go:164] CONN: Connecting to zero:5080
zero-0     | W0416 08:30:34.127242      16 node.go:713] [0x1] Read index context timed out
zero-0     | I0416 08:30:34.127519      16 zero.go:536] Connected: cluster_info_only:true
zero-0     | I0416 08:30:34.127703      16 zero.go:511] Got connection request: cluster_info_only:true
zero-0     | I0416 08:30:34.127848      16 zero.go:536] Connected: cluster_info_only:true
alpha-1    | I0416 08:30:34.128340      17 pool.go:164] CONN: Connecting to zero:5080
alpha-2    | I0416 08:30:34.128382      18 pool.go:164] CONN: Connecting to zero:5080
zero-0     | I0416 08:30:34.212028      16 zero.go:511] Got connection request: cluster_info_only:true

Looks like there is a bug in Alpha code which fallbacks to default Zero address.