# How to properly set docker-compose ports

**URL:** <https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048>\
**Category:** Dgraph\
**Created:** [August 22, 2018, 11:22am UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048 "2018-08-22T11:22:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tlmichael](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tlmichael](https://discuss.dgraph.io/u/tlmichael)\
**Post date:** [August 22, 2018, 11:22am UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/1 "2018-08-22T11:22:15Z")

</div>

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.:

```auto
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

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [August 22, 2018, 1:03pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/2 "2018-08-22T13:03:17Z")

</div>

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

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

Cheers

---

<div class="post-metadata">

**Author:** ![tlmichael](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tlmichael](https://discuss.dgraph.io/u/tlmichael)\
**Post date:** [August 22, 2018, 1:25pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/3 "2018-08-22T13:25:43Z")

</div>

The page makes me feel quite confused 😓

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?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [August 22, 2018, 2:08pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/4 "2018-08-22T14:08:46Z")

</div>

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:

```auto
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

```

```auto
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

```

---

<div class="post-metadata">

**Author:** ![tlmichael](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tlmichael](https://discuss.dgraph.io/u/tlmichael)\
**Post date:** [August 22, 2018, 4:12pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/5 "2018-08-22T16:12:10Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [August 22, 2018, 4:48pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/6 "2018-08-22T16:48:14Z")

</div>

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:

```auto
     ports:
       - 8000: 8000

```

---

<div class="post-metadata">

**Author:** ![tlmichael](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tlmichael](https://discuss.dgraph.io/u/tlmichael)\
**Post date:** [August 22, 2018, 4:54pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/7 "2018-08-22T16:54:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [August 22, 2018, 4:55pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/8 "2018-08-22T16:55:44Z")

</div>

You could cut off Ratel UI from the compose and use  
[Ratel Installer for Linux, MacOs and Windows (UPDATED 2020)](http://discuss.hypermode.com/t/ratel-installer-for-linux-macos-and-windows-preview-version-ratel-update-from-v1-0-6/2884)

PS. Or just go localhost:3200

---

<div class="post-metadata">

**Author:** ![tlmichael](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@tlmichael](https://discuss.dgraph.io/u/tlmichael)\
**Post date:** [August 22, 2018, 5:03pm UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/9 "2018-08-22T17:03:43Z")

</div>

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 😛

---

<div class="post-metadata">

**Author:** ![Jem](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jem/32/9467_2.png) [@Jem](https://discuss.dgraph.io/u/Jem)\
**Post date:** [January 19, 2022, 6:28am UTC](https://discuss.dgraph.io/t/how-to-properly-set-docker-compose-ports/3048/10 "2022-01-19T06:28:29Z")

</div>

@tlmichael where you or anyone here able to create multiple docker-compose files to run multiple dgraph instance? I would like to be able to run instance for dev, test, and staging.
