{"id":13545551,"url":"https://github.com/senssei/mongo-cluster-docker","last_synced_at":"2025-09-07T22:42:27.085Z","repository":{"id":83157635,"uuid":"77840616","full_name":"senssei/mongo-cluster-docker","owner":"senssei","description":"Docker compose config for mongodb cluster","archived":false,"fork":false,"pushed_at":"2019-03-27T03:40:00.000Z","size":29,"stargazers_count":185,"open_issues_count":2,"forks_count":100,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-08T21:03:48.012Z","etag":null,"topics":["docker","docker-compose","location-based","mongo","mongo-cluster-docker","mongodb","partitioning","replicas","router","shard","sharding"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/senssei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-02T14:52:47.000Z","updated_at":"2024-10-11T16:01:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"37aa6710-8b3c-4474-abf9-b05b8af83ac4","html_url":"https://github.com/senssei/mongo-cluster-docker","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/senssei/mongo-cluster-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/senssei%2Fmongo-cluster-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/senssei%2Fmongo-cluster-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/senssei%2Fmongo-cluster-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/senssei%2Fmongo-cluster-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/senssei","download_url":"https://codeload.github.com/senssei/mongo-cluster-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/senssei%2Fmongo-cluster-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274107986,"owners_count":25223473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","location-based","mongo","mongo-cluster-docker","mongodb","partitioning","replicas","router","shard","sharding"],"created_at":"2024-08-01T11:01:05.457Z","updated_at":"2025-09-07T22:42:27.044Z","avatar_url":"https://github.com/senssei.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# mongo-cluster-docker\n\nThis is a simple 3 node replica mongodb setup based on official `mongo` docker image using `docker-compose` described in my blogpost at https://warzycha.pl/mongo-db-sharding-docker-example/.\n\nFor details description, steps and discussion go to:\n\n1. https://warzycha.pl/mongo-db-sharding-docker-example/\n2. https://warzycha.pl/mongo-db-shards-by-location/\n\n# Run\n\n```\ndocker-compose -f docker-compose.1.yml -f docker-compose.2.yml  -f docker-compose.cnf.yml -f docker-compose.shard.yml up\n```\n\n# Tests\n\u003e Manually for the time being\n\n0. Core tests\n\nBasic *replica* test on *rs1* replica set (data nodes), `mongo-1-1`\n```js\nrs.status();\n```\n\nthis should return in `members` 3 nodes.\n\nBasic *sharding* test on *router* (mongos), `mongo-router`\n```js\nsh.status();\n```\n\nthis should return something similar to:\n\n```\n--- Sharding Status --- \n  sharding version: {\n\t\"_id\" : 1,\n\t\"minCompatibleVersion\" : 5,\n\t\"currentVersion\" : 6,\n\t\"clusterId\" : ObjectId(\"587d306454828b89adaca524\")\n}\n  shards:\n  active mongoses:\n\t\"3.4.1\" : 1\n  balancer:\n\tCurrently enabled:  yes\n\tCurrently running:  yes\n\t\tBalancer lock taken at Mon Jan 16 2017 22:18:53 GMT+0100 by ConfigServer:Balancer\n\tFailed balancer rounds in last 5 attempts:  0\n\tMigration Results for the last 24 hours: \n\t\tNo recent migrations\n  databases:\n\n```\n\n# Sharding configuration\n\nConnect to 'mongos' router and run `queries/shard-status.js` for shard status.\n\nTo establish location based partitioning on it just run `queries/init.js`.\n\n# Issues and limitations\n\nIt's sometimes stuck on 'mongo-router         | 2017-01-16T21:29:48.573+0000 W NETWORK  [replSetDistLockPinger] No primary detected for\nset cnf-serv'. It's because quite random order in `docker-compose`.\n\nMy workaround was just to kill all containers related.\n\n```\ndocker-compose -f docker-compose.1.yml -f docker-compose.2.yml  -f docker-compose.cnf.yml -f docker-compose.shard.yml rm -f\n```\n\nPlease pull request. :)\n\nBasically `mongosetup` service is now splitted to multiple `yml` files. :)\n\n# Reference\n\n* http://www.sohamkamani.com/blog/2016/06/30/docker-mongo-replica-set/\n* https://github.com/singram/mongo-docker-compose\n* http://stackoverflow.com/questions/31138631/configuring-mongodb-replica-set-from-docker-compose\n* https://gist.github.com/garycrawford/0a45f820e146917d231d\n* http://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y\n* https://docs.docker.com/compose/startup-order/\n* http://stackoverflow.com/questions/31138631/configuring-mongodb-replica-set-from-docker-compose\n* https://github.com/soldotno/elastic-mongo/blob/master/docker-compose.yml\n\nSee more @ `ENV.md`\n\nMIT @ `LICENSE`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsenssei%2Fmongo-cluster-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsenssei%2Fmongo-cluster-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsenssei%2Fmongo-cluster-docker/lists"}