Deploy with Docker Compose

Set up a three-node cluster with Docker Compose and enrolment tokens.

Set up a three-node cluster with Docker Compose. It is meant for test environments; in production, each node goes on its own machine.

Requirements

  • Docker with Compose.
  • The image version, the one in Download.

Write the file

Save this file as compose.yaml in an empty directory on the machine where you will start the nodes:

YAML
services:
  node-01:
    image: teseladb/teseladb:<version>
    command: start --dbpath /data --bind_ip 0.0.0.0 --peer-listen 0.0.0.0:27100 --admin-listen 0.0.0.0:27200
    volumes: ["node-01:/data"]
    ports: ["27017:27017"]
  node-02:
    image: teseladb/teseladb:<version>
    command: >
      start --dbpath /data --bind_ip 0.0.0.0 --peer-listen 0.0.0.0:27100 --admin-listen 0.0.0.0:27200
      --join node-01:27100 --enroll-token ${TOKEN_02}
    volumes: ["node-02:/data"]
  node-03:
    image: teseladb/teseladb:<version>
    command: >
      start --dbpath /data --bind_ip 0.0.0.0 --peer-listen 0.0.0.0:27100 --admin-listen 0.0.0.0:27200
      --join node-01:27100 --enroll-token ${TOKEN_03}
    volumes: ["node-03:/data"]
volumes:
  node-01:
  node-02:
  node-03:

Start the first node and create the tokens

Shell
docker compose up -d node-01
export TOKEN_02=$(docker compose exec node-01 teseladb admin --dbpath /data token create --ttl 1h)
export TOKEN_03=$(docker compose exec node-01 teseladb admin --dbpath /data token create --ttl 1h)

Start the other two

Shell
docker compose up -d node-02 node-03

Check

Once the three containers are running, docker compose exec node-01 teseladb admin --dbpath /data nodes lists the three nodes as active.

Common problems

  • A node does not join because its token expired or was already used. Create another and start that service again.

See also