Python SDK Docker containerization setup

Last updated: February 24, 2026

Applicable To

Plans: Any

Deployments: Any

Summary

Goal: Containerize Python SDK scripts for automated logging and cronjobs using Docker.

This the currently recommended way to containerize braintrust sdk usage.

Configuration Steps

Step 1: Create Dockerfile

Use a minimal Python base image and install the Braintrust SDK.

FROM python:3.11-slim

WORKDIR /app

RUN pip install --no-cache-dir braintrust

COPY . .

ENV BRAINTRUST_API_KEY=""

CMD ["python", "your_script.py"]

Step 2: Set API key at runtime

Pass your Braintrust API key as an environment variable when running the container.

docker run -e BRAINTRUST_API_KEY=your_api_key your_image

Step 3: Add dependencies

If your script requires additional packages, add a requirements.txt file.

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .

Notes

  • Braintrust does not publish an official Docker image

  • Python 3.9+ is required

  • Use standard Docker best practices for production deployments