Skip to main content
Use Basecut with Docker Compose to automatically restore snapshots when starting your local development environment. This ensures every developer starts with the same realistic dataset.

Overview

This guide shows how to:
  • Add Basecut CLI to your Docker Compose setup
  • Restore snapshots as part of docker compose up
  • Use BASECUT_DATABASE_URL with Docker networks
  • Share snapshots across your team
This guide focuses on local execution - Basecut CLI runs in a container and connects to your database container. For production workloads, see Agent Deployment.

Basic Setup

1. Add Basecut Service to docker-compose.yml

Add a Basecut service that runs after your database is ready:

2. Restore Snapshot on Startup

Run Basecut restore as part of your startup:

Using Docker Networks

When your database is in a Docker network, use the service name as the hostname:

Custom Basecut Image

Create a custom Docker image with Basecut pre-installed for faster startup:
Build and use:
Then reference in docker-compose.yml:

Environment Variables

Store Basecut credentials securely:

Option 1: .env File (Local Development)

Docker Compose automatically loads .env:

Option 2: Docker Secrets (Production)

For production, use Docker secrets and export the value before running Basecut:

Complete Example

Full docker-compose.yml with app, database, and Basecut:
Usage:

Tips

  • Use profiles: The profiles directive lets you run Basecut restore only when needed, not on every docker compose up
  • Health checks: Ensure your database is healthy before restoring (prevents connection errors)
  • Volume mounts: Mount basecut.yml and snapshot directories if using local storage
  • Idempotency: Use --yes flag to skip confirmation prompts in CI/automated environments

Next Steps