Skip to content

Instantly share code, notes, and snippets.

@lucassardois
Last active June 17, 2024 17:24
Show Gist options
  • Save lucassardois/488425f3066fc19c6179733516c3152d to your computer and use it in GitHub Desktop.
Save lucassardois/488425f3066fc19c6179733516c3152d to your computer and use it in GitHub Desktop.
A simple docker-compose file to enable MongoDB replica set using a single node setup.
version: '3.0'
services:
mongo:
image: mongo:4.4
ports:
- '27017:27017'
command: mongod --replSet rs0
healthcheck:
test: test $$(echo "rs.initiate({_id:'rs0',members:[{_id:0,host:\"127.0.0.1:27017\"}]}).ok || rs.status().ok" | mongo --host mongo:27017 --quiet) -eq 1
interval: 5s
timeout: 5s
start_period: 5s
retries: 5
@lucassardois
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment