Thursday 20 April 2017

nodejs doesn't connect to rethinkdb with docker-compose

How run rethinkdb with nodejs on server ?

Is docker-compose.yml:

web:
  build: ./app
  volumes:
    - "./app:/src/app"
  ports:
    - "8000:8000"
    - "8080:8080"
    - "28015:28015"
    - "29015:29015"
  links:
    - "db:redis"
    - "rethink:rethinkdb"
  command: nodemon -L app/bin/www

db:
  image: redis
  ports:
    - "6379"
rethink:
  image: rethinkdb

is a folder app with nodejs-project and Dockerfile

Dockerfile

FROM node:0.10.38

RUN mkdir /src

RUN npm install nodemon -g

WORKDIR /src/app
ADD package.json package.json
RUN npm install

ADD nodemon.json nodemon.json

In the nodejs-project connection to rethinkdb:

module.exports.setup = function() {
  r.connect({host: dbConfig.host /* 127.0.0.1*/, port: dbConfig.port /*is 28015 or 29015 or 32783*/ }, function (err, connection) {
    ...
  });
};

And when run a docker-compose up, have an error

Could not connect to 127.0.0.1:32783.

enter image description here



via vos.brother

No comments:

Post a Comment