To deploy a single instance of RethinkDB we can use the following script:

#!/bin/bash

HOME=/usr/src/data
DATA_DIR="$HOME/rethinkdb";
mkdir -p $DATA_DIR

docker run -d \
    --name rethinkdb \
    -h `hostname` \
    -p 8080:8080 \
    -p 28015:28015 \
    -p 29015:29015 \
    -v $DATA_DIR:/data rethinkdb \
    rethinkdb \
    -d /data \
    --bind all \
    --canonical-address `curl icanhazip.com`

Here we use icanhazip.com to retrieve our machine's IP.

You can now access the Web UI at the port 8080 of your host:

http://localhost:8080

You can log on your container to interact with the rethinkdb cli tool:

docker exec -ti rethinkdb /bin/bash

Security

The Web UI admin panel does not have any sort of authentication. You will need to do this by either restricting the web interface port using RethinkDB's --bind-http command line option or if you are hosting the database in AWS using Security Groups and restricting IP's there.

You can read about RethinkDB user permissions and accounts

Create a new user:

r.db('rethinkdb').table('users').insert({id: 'node-client', password: 'secret'})

You can update your admin password:

r.db('rethinkdb').table('users').get('admin').update({password: 'secret'})

Setting up TLS

RethinkDB Cluster

Cluster using Docker

Note that it is safe to pass it's own hostname to RethinkDB, it will ignore connections to itself.

When starting a cluster, you should pass one or more --canonical-address directive(s) to customize which HOST/IP RethinkDB uses to advertise itself to other hosts. Otherwise it won't start.

To start a 2 node cluster on 2 hosts:

  • First host host1.example.com:
docker run -d \
    --name rethinkdb \
    -h `hostname` \
    -p 8080:8080 \
    -p 28015:28015 \
    -p 29015:29015 \
    -v $DATA_DIR:/data rethinkdb \
    rethinkdb \
    -d /data \
    --bind all \
    --join host1.example.com \
    --join host2.example.com \
    --canonical-address `curl icanhazip.com`
  • First host host2.example.com:
docker run -d \
    --name rethinkdb \
    -h `hostname` \
    -p 8080:8080 \
    -p 28015:28015 \
    -p 29015:29015 \
    -v $DATA_DIR:/data rethinkdb \
    rethinkdb \
    -d /data \
    --bind all \
    --join host1.example.com \
    --join host2.example.com \
    --canonical-address `curl icanhazip.com`

You can follow this guide at dockerfile to get a sense of how it works.

Cluster using Docker Swarm

K8

If you prefer to run your application using Kubernets there is a pretty detailed README in the [this][kubernetes-rethinkdb-cluster] repo.

Using RethinkDB with Waterline

The only [waterline-rethinkdb][waterline-rethinkdb] driver is not being maintained at the moment.

  • Driver does not support drop
  • First time you run seed it will create tables but will fail to create documents, you need to run the queries twice.