Run duh in a container with persistent storage and no local Python installation required.
- Docker (with Compose v2)
- API keys for at least one provider
Build and run:
docker compose run duh ask "What are the trade-offs of microservices vs monolith?"That's it. Docker Compose builds the image, creates a persistent volume for the database, and passes your API keys from the host environment.
Export your keys in the host shell:
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...Docker Compose forwards these to the container via the environment section in docker-compose.yml.
!!! warning "Don't put API keys in docker-compose.yml" The compose file references environment variables by name (without values). Your keys stay in your shell environment, not in version-controlled files.
docker compose buildThe Dockerfile uses a multi-stage build:
- Builder stage -- Installs dependencies with
uv sync --no-dev --frozen - Runtime stage -- Copies the virtual environment and source code into a slim Python 3.11 image
The runtime image runs as a non-root duh user (UID 1000).
# Ask a question
docker compose run duh ask "your question"
# Search past decisions
docker compose run duh recall "topic"
# List threads
docker compose run duh threads
# Show a specific thread
docker compose run duh show a1b2c3d4
# List models
docker compose run duh models
# Check costs
docker compose run duh costThe database is stored in a Docker volume (duh-data) mounted at /data inside the container. The Docker-specific config file (docker/config.toml) sets:
[database]
url = "sqlite+aiosqlite:////data/duh.db"Your data persists across container restarts and rebuilds.
docker volume inspect duh_duh-datadocker compose run duh cat /data/duh.db > backup.dbdocker volume rm duh_duh-dataMount a custom config file:
docker compose run -v ./my-config.toml:/app/config.toml duh ask "question"Or modify docker-compose.yml to add the mount permanently:
services:
duh:
build: .
volumes:
- duh-data:/data
- ./my-config.toml:/app/config.toml
environment:
- ANTHROPIC_API_KEY
- OPENAI_API_KEYThe included docker-compose.yml:
services:
duh:
build: .
volumes:
- duh-data:/data
environment:
- ANTHROPIC_API_KEY
- OPENAI_API_KEY
volumes:
duh-data:- Configuration -- Full config options
- Local Models -- Connect to Ollama running on the host