backtest-kit-redis-mongo-docker ships three separate Docker Compose files: one for MongoDB, one for Redis, and one for the main backtest container. Keeping the infrastructure containers in their own files means you can start and stop the database layer independently from the application, making it easy to preserve data between backtest runs or share a single MongoDB/Redis instance across multiple projects.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/theonetrade/backtest-kit-redis-mongo-docker/llms.txt
Use this file to discover all available pages before exploring further.
MongoDB Container
The MongoDB service uses the official MongoDB Community Server image and persists all data to a local directory on the host so that candle history and trade records survive container restarts.Image
mongodb/mongodb-community-server:8.0.4-ubi8 — MongoDB 8.0.4 on UBI 8. Pin the tag to guarantee reproducible infrastructure across machines.Port
Host port
27017 maps to container port 27017. Ensure this port is not already occupied before starting.Volume
./mongo_data:/data/db — all collections and indexes are stored in docker/mongodb/mongo_data/ on the host. Delete this directory to reset the database.Restart policy
always — MongoDB restarts automatically after host reboots or unexpected exits.Start MongoDB
Stop MongoDB
Redis Container
The Redis service provides the O(1) ID cache layer. Password authentication is enforced via--requirepass so that the same credential set can be used in both local and Docker environments.
Image
redis:7.4.1 — Redis 7.4.1 with RDB persistence enabled by default.Port
Host port
6379 maps to container port 6379. The application connects using CC_REDIS_PORT=6379.Password
mysecurepassword is set via --requirepass. Must match CC_REDIS_PASSWORD in your .env file.Volume
./redis_data:/data — RDB snapshots are written here. Delete to start with a clean cache.Start Redis
Stop Redis
Changing the Redis Password
Update the Redis Compose file
Edit
docker/redis/docker-compose.yaml and replace both occurrences of mysecurepassword — one in the environment block and one in the command array:Update .env
Set the matching value in your
.env file so the Node.js process authenticates with the same credential:Main Backtest Container
The primary application container runs the compiled backtest-kit strategy bundle. It connects back to MongoDB and Redis on the host using thehost.docker.internal bridge hostname.
Image
tripolskypetr/backtest-kit (linux/amd64). The platform key ensures consistent behaviour on Apple Silicon and other ARM hosts.Port
60050:60050 — the web UI and health-check API are exposed on this port.Volume
./:/workspace — the entire project directory is mounted at /workspace inside the container, making your compiled strategy bundle immediately available without rebuilding the image.Restart policy
unless-stopped — the container restarts automatically after unexpected exits but stays stopped if you run docker-compose down manually.Start the Main Container
npm run build first, then starts the container with MODE=backtest ENTRY=1 UI=1 STRATEGY_FILE=./build/index.cjs.
Stop the Main Container
Container-to-Host Networking with host.docker.internal
By default, localhost inside a Docker container refers to the container’s own loopback interface, not the host machine. The extra_hosts directive in the backtest container Compose file injects a special DNS entry:
host.docker.internal to the host machine’s gateway IP, allowing the container to reach services bound to the host’s network. This is why .env.example uses host.docker.internal rather than localhost:
host.docker.internal is natively available on Docker Desktop for Mac and Windows. The host-gateway mapping in extra_hosts provides the same hostname on Linux hosts where it is not injected automatically.Health Check
The backtest container includes a Docker health check that polls the application’s REST endpoint once the UI is running:| Parameter | Value |
|---|---|
| Endpoint | GET http://localhost:60050/api/v1/health/health_check |
| Interval | 30 seconds |
| Timeout | 10 seconds |
| Retries | 3 |