How to properly set docker-compose ports

My situation is that I would like to run multiple Dgraph docker containers on the same machine, but I’m a bit confused about the process of changing ports and using the port-offset.

I’ve tried to modify all the ports in the docker-compose file, e.g.:

version: "3.2"
services:
  zero:
    image: dgraph/dgraph:latest
    volumes:
      - ./_dgraphdata:/dgraph
    ports:
      - 3001:5080
      - 3002:6080
    restart: on-failure
    command: dgraph zero --my=zero:3001
  server:
    image: dgraph/dgraph:latest
    volumes:
      - ./_dgraphdata:/dgraph
    ports:
      - 3100:8080
      - 3101:9080
    restart: on-failure
    command: dgraph server --my=server:7080 --lru_mb=2048 --zero=zero:3001
  ratel:
    image: dgraph/dgraph:latest
    ports:
      - 3200:8000
    command: dgraph-ratel

but doing so results in the following error: groups.go:105: Error while connecting with group zero: rpc error: code = Unavailable desc = all SubConns are in TransientFailure

Tbh, I’m a bit confused about why zero and server have two ports, and I’m guessing it’s a problem that ratel doesn’t know what port server is running on.

The purpose of the docker-compose file I wrote above is that I would like to connect to port 3001, and I would like the admin interface to be available on port 3050

Dgraph’s ports has it’s own rules that you need to follow.

Here take a read https://docs.dgraph.io/deploy/#ports-usage

Cheers

The page makes me feel quite confused :sweat:

By any chance you could help provide 2 docker-compose files that could run on the same machine? Preferable where the ports for each docker-compose is closely aligned, e.g. 3000, 3001, 3002, 3003, 3004, 3005, 3006 for one file, and 3100, 3101, 3102, 3103, 3104, 3105, 3016 for the other, assuming this is even possible?

You have to use --port_offset tho

Try an ideal combination for you. Each Dgraph instance needs to be in the exact offset.

e.g:

dgraph zero --port_offset -3001

Setting up grpc listener at: 0.0.0.0:2079
Setting up http listener at: 0.0.0.0:3079
dgraph zero --port_offset -1999

Setting up grpc listener at: 0.0.0.0:3081
Setting up http listener at: 0.0.0.0:4081
1 Like

If I use the following docker-compose file then it runs (thanks to your --port offset but slightly modified the value), but cannot load the Dgraph browser, it just responds with text saying:

Dgraph browser is available for running separately using the dgraph-ratel binary

This is the docker-compose file:

version: "3.2"
services:
  zero:
    image: dgraph/dgraph:latest
    volumes:
      - ./_dgraphdata:/dgraph
    ports:
      - 3001:5080
      - 4001:6080
    restart: on-failure
    command: dgraph zero --my=zero:3001 --port_offset -2079
  server:
    image: dgraph/dgraph:latest
    volumes:
      - ./_dgraphdata:/dgraph
    ports:
      - 3100:8080
      - 3101:9080
    restart: on-failure
    command: dgraph server --my=server:7080 --lru_mb=2048 --zero=zero:3001
  ratel:
    image: dgraph/dgraph:latest
    ports:
      - 3200:8000
    command: dgraph-ratel

I would think this docker-compose file would mean that the Dgraph browser should be available at localhost:3100?

Ratel UI is a completely different Dgraph binary. It does not follow the use of the flag --port_offset. Using this flag affects only the binary you start with it.

Therefore:

     ports:
       - 8000: 8000

It is possible for ratel to specify server port? If not, then I assume it would be impossible to simultaneously run two separate Dgraph instances on the same machine?

You could cut off Ratel UI from the compose and use
Ratel Installer for Linux, MacOs and Windows (Preview version | Ratel Update from v1.0.6)

PS. Or just go localhost:3200

1 Like

Oh wow… my bad… when I had opened localhost:3200 then I didn’t notice the change URL part… thanks a lot, the --port_offset also seem to work perfectly in terms of using very specific ports…

It was previously my understanding that using port_offset would offset all ports for zero+server+ratal, so that you would decrease/increase all of them simultaneously… but happy to know I was wrong about that :stuck_out_tongue:

1 Like