Docker Containers Defined in docker-compose for AI Hedge Fund: Complete Service Reference

The virattt/ai-hedge-fund repository defines six specialized Docker containers in docker/docker-compose.yml to orchestrate live trading, reasoning analysis, historical backtesting, and optional local LLM inference via Ollama.

The virattt/ai-hedge-fund project containerizes its AI-driven trading platform using a single Docker Compose configuration. This setup ensures environment consistency by declaring distinct services for trading execution, backtesting, and local language model hosting. Understanding these Docker containers defined in docker-compose is essential for deploying the hedge fund engine with correct operational parameters and connectivity.

Service Architecture Overview

According to the source code analysis, the docker/docker-compose.yml file (located in the repository's docker/ directory) declares six containerized services and one persistent volume. All Python-based services build from the same image defined in docker/Dockerfile but execute different entry point commands to fulfill specific roles in the trading pipeline.

Container Definitions in docker-compose.yml

Ollama LLM Server (ollama)

The ollama service provides optional local LLM inference using the ollama/ollama:latest image, as defined in lines 2-16 of the compose file. It exposes port 11434 to the host and configures GPU acceleration for Apple Silicon via METAL_DEVICE=on and METAL_DEVICE_INDEX=0. The service mounts the named volume ollama_data to /root/.ollama to persist downloaded models across restarts. Environment variables include OLLAMA_HOST=0.0.0.0 to allow external connections from sibling containers.

Live Trading Engine (hedge-fund)

The primary application container builds from ../docker/Dockerfile and executes python src/main.py --ticker AAPL,MSFT,NVDA (lines 18-32). It mounts the project-root .env file to inject API keys and runtime configuration. Critical environment variables include OLLAMA_BASE_URL (pointing to the Ollama service), PYTHONUNBUFFERED=1 for real-time logging, and PYTHONPATH=/app for proper module resolution within the container.

Reasoning-Enabled Trading (hedge-fund-reasoning)

This container extends the base trading engine with the --show-reasoning flag, executing python src/main.py --ticker AAPL,MSFT,NVDA --show-reasoning as specified in lines 33-47. The configuration is otherwise identical to the standard hedge-fund service, but outputs LLM-generated trade justifications alongside execution results.

Ollama-Forced Trading (hedge-fund-ollama)

Designed to bypass external LLM configurations, this service appends the --ollama flag to force local inference through the Ollama endpoint. It runs python src/main.py --ticker AAPL,MSFT,NVDA --ollama according to lines 48-62, strictly relying on the OLLAMA_BASE_URL environment variable.

Historical Backtesting (backtester)

The backtester container executes the simulation pipeline via python src/backtester.py --ticker AAPL,MSFT,NVDA (lines 63-77). It uses the same image and environment variables as the trading services but invokes src/backtester.py to run historical strategy validation rather than live trading.

Local LLM Backtesting (backtester-ollama)

This variant adds the --ollama flag to the backtest command, running python src/backtester.py --ticker AAPL,MSFT,NVDA --ollama as defined in lines 78-92. This configuration tests strategies using local LLM reasoning capabilities instead of external API endpoints.

Shared Configuration and Profiles

All Python-based containers share consistent environment settings to ensure proper execution context. The PYTHONUNBUFFERED=1 setting ensures unbuffered stdout/stderr streams for real-time log visibility, while PYTHONPATH=/app guarantees correct import resolution for the application's module structure. The ollama service is gated behind the embedded-ollama Docker Compose profile, allowing users to run the stack with external LLM endpoints by omitting the profile flag.

Volume Persistence and Data Management

The ollama_data volume maps to /root/.ollama inside the Ollama container (lines 93-95), preventing model re-downloads between container restarts. Trading and backtesting services mount the host's .env file to provide runtime configuration without baking secrets into the image.

Running the Docker Containers

Execute these commands from the repository root to orchestrate the services:


# Start the full stack with embedded Ollama server

docker compose --profile embedded-ollama up -d

# Run only the live trading engine (no reasoning output, no local LLM)

docker compose up -d hedge-fund

# Run the engine with reasoning displayed

docker compose up -d hedge-fund-reasoning

# Execute a back-test using the local Ollama LLM

docker compose up -d backtester-ollama

# Tear everything down and remove volumes

docker compose down -v

Use docker compose logs -f <service> to stream real-time output from any specific container.

Summary

  • The docker/docker-compose.yml file defines six distinct containers: ollama, hedge-fund, hedge-fund-reasoning, hedge-fund-ollama, backtester, and backtester-ollama.
  • All trading services build from docker/Dockerfile and share environment variables PYTHONUNBUFFERED=1 and PYTHONPATH=/app for consistent runtime behavior.
  • The Ollama service provides optional local LLM inference on port 11434 with GPU acceleration support for Apple Silicon.
  • Docker Compose profiles control service activation: use --profile embedded-ollama to enable the local LLM server.
  • The ollama_data volume persists model files to /root/.ollama, while the .env file mount injects runtime configuration into trading containers.

Frequently Asked Questions

What Docker containers are defined in the docker-compose file?

The docker/docker-compose.yml file defines six containers: the ollama LLM server, the main hedge-fund trading engine, hedge-fund-reasoning for trade justification outputs, hedge-fund-ollama for forced local LLM usage, the backtester for historical simulations, and backtester-ollama for local LLM backtesting. All Python services use the same base image built from docker/Dockerfile but execute different CLI arguments to specialize their function.

How do I run the AI Hedge Fund with a local LLM?

Start the stack with the embedded-ollama profile using docker compose --profile embedded-ollama up -d. This activates the Ollama container on port 11434 and configures the OLLAMA_BASE_URL environment variable for trading containers. Alternatively, launch docker compose up -d hedge-fund-ollama to force Ollama usage for a specific trading instance regardless of other configuration.

What is the difference between hedge-fund and hedge-fund-reasoning containers?

Both containers execute the live trading engine from src/main.py, but hedge-fund-reasoning appends the --show-reasoning flag to display LLM-generated explanations for each trade decision. The standard hedge-fund container runs without verbose reasoning output, making it suitable for automated production deployments where only execution results are required.

Where is the docker-compose configuration located?

The Docker Compose configuration resides at docker/docker-compose.yml in the repository root. The file references the build context from ../docker/Dockerfile (relative to the compose file location) and mounts configuration files from the project root directory, including the .env file and source code directories.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →