Created
February 21, 2018 23:28
-
-
Save mpowaga/e1f386efedc73837f4a7fac4ef3c3136 to your computer and use it in GitHub Desktop.
Mongo Replica Set with Docker Compose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3" | |
services: | |
master: | |
image: mongo | |
links: | |
- slave | |
networks: | |
- mongo-cluster | |
volumes: | |
- ./init-repl-set.sh:/docker-entrypoint-initdb.d/init-repl-set.sh | |
command: mongod --replSet replset | |
ports: | |
- "27017:27017" | |
slave: | |
image: mongo | |
networks: | |
- mongo-cluster | |
command: mongod --replSet replset | |
networks: | |
mongo-cluster: | |
driver: bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(sleep 5 && mongo --eval "rs.initiate({_id: 'replset', members: [{_id: 0, host: 'master:27017'}, {_id: 1, host: 'slave:27017'}]})")& |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment