Last active
June 17, 2024 17:24
-
-
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.
This file contains 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.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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check the linked article here: https://lucassardois.medium.com/mongodb-replica-set-on-docker-compose-6331a9682943.