graft init
Initialize Graft on a target database container. This is the first command you run — it bridges the container’s Docker volume to the host filesystem and sets up the Graft project structure.
Usage
Behavior
- Inspects the target container (image, env, ports, network, volumes)
- Prompts you to select which Docker volume contains the database data
- Stops the container
- Copies data from the Docker volume to
~/.graft/<container>/branches/main/via an ephemeral Alpine runner - Sets up the
graft.dbSQLite DAG store andobjects/directory - If
--bind, recreates the container with a host bind mount - Starts the container
- Saves the state to
config.json
Flags
| Flag | Alias | Default | Description |
|---|---|---|---|
--volume | -v | "" | Volume name (skips interactive prompt) |
--bind | false | Take over container lifecycle (recreate with bind mount) |
Examples
Interactive Init
With Explicit Volume
With Bind Mount
Output
Modes
| Mode | Flag | Container | Best For |
|---|---|---|---|
| Snapshot | (default) | Left on original Docker volume | Quick setup, manual management |
| Bind | --bind | Recreated with host bind mount | Full Graft-managed lifecycle |
graft commit bridges from the Docker volume to the host. In bind mode, the container’s data lives directly on the host and no bridging is needed.
Exit Codes
| Code | Meaning |
|---|---|
0 | Initialized successfully |
1 | Error (container not found, no volumes, already initialized) |