# Docker Compose Block Producer

> Run a Mina Block Producer node using Docker Compose.

Canonical URL: https://docs.minaprotocol.com/node-operators/block-producer-node/docker-compose

Run a Mina block producer node as a separate container, with control over resource allocation, logging, and restarts.

The full Docker Compose configuration — including `docker-compose.yml`, example environment files for mainnet and devnet, a `Makefile`, and a `README` — is maintained in the Mina repository:

**[`mina/src/app/cli/docker-compose/block-producer/`](https://github.com/MinaProtocol/mina/tree/compatible/src/app/cli/docker-compose/block-producer)**

## Quick start

:::tip
Before running the commands below, review the [Configuration](#configuration) section to see all available options — including image tags, network selection, and ports.
:::

```bash
git clone https://github.com/MinaProtocol/mina.git
cd mina/src/app/cli/docker-compose/block-producer

# For mainnet
cp example.mainnet.env .env

# For devnet
cp example.devnet.env .env

# Edit .env — set MINA_PRIVKEY_PASS and MINA_LIBP2P_PASS (both required)
vi .env

# Start services
docker compose --env-file .env up -d

# Or use make shortcuts
make mainnet   # copies mainnet env and starts services
make devnet    # copies devnet env and starts services
```

:::note
Every `docker compose` command on this page passes `--env-file .env`. Docker Compose reads `.env` on its own, but other runtimes, such as Podman, do not.
:::

## Services overview

| Service | Description | Default Port |
|---------|-------------|--------------|
| **generate_wallet_key** | One-shot: generates the block producer keypair (skipped if one already exists) | — |
| **mina_block_producer** | Mina daemon running with `--block-producer-key` | 3085 (GraphQL), 8302 (P2P) |

## Configuration

All configuration is done through a single `.env` file. Key variables:

### Docker image

| Variable | Description |
|----------|-------------|
| `MINA_DAEMON_IMAGE` | Mina daemon Docker image |

The image, for mainnet and devnet, is pulled from [Docker Hub](https://hub.docker.com/u/minaprotocol) (`minaprotocol/mina-daemon`).

### Network

| Variable | Description |
|----------|-------------|
| `MINA_NETWORK` | `mainnet` or `devnet` |
| `MINA_PEERLIST_URL` | Bootstrap peers URL |
| `MINA_PRIVKEY_PASS` | Passphrase for the block producer key (required) |
| `MINA_LIBP2P_PASS` | Passphrase for the libp2p key (required) |

### Ports

| Variable | Default | Description |
|----------|---------|-------------|
| `MINA_REST_PORT` | `3085` | GraphQL API port |
| `MINA_P2P_PORT` | `8302` | P2P networking port (must be reachable from the internet) |

## Funding the block producer

After the wallet key is generated, your block producer's public key is stored at `./mina_node/.mina-config/keys/wallet-key.pub` on the host. Block production only kicks in once that account holds (or is delegated) staking funds.

```bash
cat ./mina_node/.mina-config/keys/wallet-key.pub
```

## Data persistence

Bind mounts preserve data across `docker compose down` / `up`:

| Host path | Container path | Contents |
|-----------|---------------|----------|
| `./mina_node/.mina-config` | `/root/.mina-config` | Daemon config, block producer key, libp2p key, peers |

## Make targets

| Command | Description |
|---------|-------------|
| `make devnet` | Copy devnet env and start services |
| `make mainnet` | Copy mainnet env and start services |
| `make stop` | Stop services |
| `make clean` | Stop services, remove volumes and `.mina-config` |
| `make logs` | Follow logs |
| `make status` | Show container status |
| `make health` | Check GraphQL endpoint, sync status, and container summary |

## Verifying the deployment

Once services are running and the daemon is connected to peers:

```bash
make health

docker compose --env-file .env exec mina_block_producer mina client status

curl -s http://localhost:3085/graphql -H 'Content-Type: application/json' \
  -d '{"query":"{ daemonStatus { syncStatus blockchainLength } }"}' | jq .
```

## Clean start

```bash
make clean
docker compose --env-file .env up -d
```

:::warning
`make clean` removes `./mina_node/.mina-config`, which contains your **block producer key**. Back up `./mina_node/.mina-config/keys/` before running it if you want to keep the key.
:::
