metricbeat/module/mongodb/collstats/testing/mongodb/README.md
This directory provides minimal Docker Compose setups to run MongoDB locally for testing.
Available setups:
standalone/ – single MongoDB instancereplica_set/ – a MongoDB replica setsharded/ – a sharded MongoDB clusterThese setups use Docker images like ${MONGO_IMAGE:-mongo}:${MONGO_VERSION:-7.0}. If you don’t set MONGO_VERSION, it defaults to 7.0.
To run a specific MongoDB version, prefix your compose command with the variable (examples for zsh):
# Use MongoDB 5.0
MONGO_VERSION=5.0 docker-compose up -d
# Or with Docker Compose V2 syntax
MONGO_VERSION=7.0 docker compose up -d
You can also override the image name if needed:
MONGO_IMAGE=mongo MONGO_VERSION=7.0 docker-compose up -d
Run each from its own subdirectory.
cd standalone
docker-compose up -d
./seed-standalone.sh
cd replica_set
docker-compose up -d
./init-replica-set.sh
cd sharded
docker-compose up -d
./init-sharded-cluster.sh
./verify-sharding.sh
From within a subdirectory:
docker-compose down -v
These environments are for local testing only.