Container Lifecycle
Graft manages the container lifecycle by recreating it with a host bind mount pointing at the current branch directory.Bind Mounts
A Docker bind mount maps a host directory directly into the container:Smart Lifecycle
Graft always captures whether the container was running before any lifecycle operation:- Stop is skipped
- Start is skipped
- Only the recreate happens
- Graceful stop (SIGTERM)
- Recreate with new bind mount
- Start
graft checkout on an already-stopped container is faster — only the filesystem work and container recreation happen.
Recreate Flow
Container Metadata Fidelity
When Graft recreates a container, it faithfully reproduces the original configuration:
The container’s identity (name) stays the same, so Docker Compose and other tools that reference the container by name continue to work.
Why Stop the Container?
Database engines cannot be safely snapshotted while running. Postgres uses a Write-Ahead Log (WAL) for durability. Copying data while Postgres is writing would produce:- Half-written WAL segments
- Incomplete
pg_wal/directory - Corrupted heap files
Performance Impact
Bind Mount Performance (macOS)
For development workloads, even the slowest environment is acceptable. Production-grade throughput is not a goal — Graft is a development tool.
Snapshot Mode (No Container Management)
Without--bind, Graft leaves the container on its original Docker volume. At commit time, an ephemeral Alpine runner copies data from the Docker volume to the host. The container is never recreated.
This mode has higher commit latency (the Alpine runner must spin up and copy data) but zero container lifecycle risk.