Skip to content

Instantly share code, notes, and snippets.

@ravshansbox
Last active September 16, 2023 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravshansbox/a5c113e3d911d0a578aad81494b4bf85 to your computer and use it in GitHub Desktop.
Save ravshansbox/a5c113e3d911d0a578aad81494b4bf85 to your computer and use it in GitHub Desktop.
services:
mongo1:
image: mongo
ports:
- 127.0.0.1:27017:27017
volumes:
- ./mongo1:/data/db
command: mongod --replSet replicaSet1
mongo2:
image: mongo
ports:
- 127.0.0.1:27018:27017
volumes:
- ./mongo2:/data/db
command: mongod --replSet replicaSet1
mongo:
image: mongo
depends_on:
- mongo1
- mongo2
command: >
sh -c "sleep 5 && mongosh --host mongo1:27017 --eval
\"
rs.initiate({
_id : 'replicaSet1',
members : [
{ _id: 0, host: 'mongo1:27017' },
{ _id: 1, host: 'mongo2:27017' }
]
});
\"
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment