Configuring MongoDB replica set from docker-compose Configuring MongoDB replica set from docker-compose elasticsearch elasticsearch

Configuring MongoDB replica set from docker-compose


I fixed the problem by putting the config in setup.sh which I called from entrypoint.

mongosetup:  image: mongo:3.0  links:    - mongo1:mongo1    - mongo2:mongo2    - mongo3:mongo3  volumes:    - ./scripts:/scripts  entrypoint: [ "/scripts/setup.sh" ]

setup.sh

#!/bin/bashMONGODB1=`ping -c 1 mongo1 | head -1  | cut -d "(" -f 2 | cut -d ")" -f 1`mongo --host ${MONGODB1}:27017 <<EOF   var cfg = {        "_id": "rs",        "version": 1,        "members": [            {                "_id": 0,                "host": "${MONGODB1}:27017",[cut..]EOF

I have created a setup with docker-compose that starts 3 MongoDBs in a replica set and ElasticSearch with mongodb-river.

It's available at https://github.com/stabenfeldt/elastic-mongo