Search code examples
mongodbfig

Docker Fig MongoDB Master Slave


im really new to docker and fig, maybe fig isnt the right tool. I try to get a master slave mongodb construct running on my machine.

what i did so far in fig (fig.yml)

redis:
  image: redis
  ports:
      - "6379:6379"

mongomaster:
  image: mongo
  ports:
      - "27017:27017"

mongoslave1:
  image: mongo
  links: 
      - mongomaster

mongoslave2:
  image: mongo
  links: 
      - mongomaster

would this be the right way to do this ? or would i use fig scale ?

how can i pass the slave parameter like here http://docs.mongodb.org/manual/core/master-slave/

mongod --slave --source <masterhostname><:<port>>

to make my mongoslave[1-2] a real slave of mongomaster ?

My aim is to type fig up and the 2 slaves should be the slave of mongomaster

Thanks for your help


Solution

  • Add a command to specify the host

    mongoslave1:
      image: mongo
      links: 
      - mongomaster
      command: mongod --slave --source mongomaster