# mongo-provision **Repository Path**: mirrors_mongodb-labs/mongo-provision ## Basic Information - **Project Name**: mongo-provision - **Description**: Containerized provisioning of MongoDB clusters for testing - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-19 - **Last Updated**: 2026-03-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Mongo Provision This tool provisions a MongoDB cluster for testing. All nodes of the cluster run in a single container. ## Example Usage - Docker Hub ``` # Start a 3-node replica set: docker run -it --rm -p27017-27019:27017-27019 felipegasper298/mongo-provision 8.0 --replicaset --nodes 3 # … or, for a sharded cluster: docker run -it --rm -p27017:27017 felipegasper298/mongo-provision 8.0 --replicaset --sharded 3 --nodes 3 ``` The above will hang indefinitely until you kill it, e.g., via CTRL-C. Then, in another terminal, run: ``` # for the replset: mongosh mongodb://localhost:27017,localhost:27018,localhost:27019 # … or, for sharded: mongosh mongodb://localhost:27017 ``` … and you’re in! ## Example Usage - Local Build the container: ``` docker build . -t mongo-provision ``` … then it’s the same as the above but with a local `mongo-provision` image instead of `felipegasper298/mongo-provision`. ## Syntax The arguments to the container are: - a version number (e.g., `8.0`) to give to [m](https://github.com/aheckmann/m) - args for [mtools](https://github.com/rueckstiess/mtools)’s `init` subcommand ## Preserving state This container stores its state (e.g., mongod data files) under `/data`. To introspect that state outside the container, mount a volume to that path in the container. ## Readiness checks To check whether the cluster is ready, `exec` into the container and check if the `ready` file exists. For example: ``` while ! docker exec my-container-name [ -e ready ]; do echo "Still waiting for cluster to be ready …" sleep 1 done ``` The `ready` file is a JSON file with the following data points: - `connection_string` (mongoses for sharded clusters) - `shards`: a dictionary of shard name to connection string ## Caveats - You **MUST** anticipate the bound ports and export them. - The container’s platform will dictate server version availability. For example, you can’t create pre-v5 clusters on Linux/ARM64 because no official builds were made for that version/platform combination. (Try `--platform linux/amd64` on multi-platform container engines.) ## Acknowledgements This uses: - [mtools](https://github.com/rueckstiess/mtools) - [m](https://github.com/aheckmann/m)