Skip to content

About

Building and publishing primitives for lightweight Mina network Docker images

Resources

Stars

1 star

Watchers

10 watching

Forks

Latest commit

 

History

110 Commits

Folders and files

Repository files navigation

Lightweight Mina Network Docker Images

Spin up a lightweight Mina network within a single container.

These Docker images provide a simple and efficient way to deploy and run lightweight Mina blockchain networks for testing purposes. It is an implementation of the Dockerization of Mina local networks RFC.

Each Docker image is packaged with a genesis ledger configuration containing more than 1000 prefunded accounts. Each account has a balance of 1550 MINA.

Table of Contents

Related Projects

Related Documentation

Quick Start

docker run --rm --pull=always -it \
  --env NETWORK_TYPE="single-node" \
  --env PROOF_LEVEL="none" \
  -p 3085:3085 \
  -p 5432:5432 \
  -p 8080:8080 \
  -p 8181:8181 \
  -p 8282:8282 \
  o1labs/mina-local-network:latest-lightnet

Wait for the network to synchronize (1-2 minutes for single-node), then connect your application to http://127.0.0.1:8080/graphql.

Specifications

  • This Docker image exposes port 8080 served by the NGINX reverse proxy with proper cross-origin resource sharing (CORS) management, which passes requests to an available Mina Daemon GraphQL endpoint.
  • To ensure that o1js zkApps applications work without additional environment configuration, use an endpoint like http://127.0.0.1:8080/graphql to communicate with the Mina GraphQL endpoint.
  • By default, containers run the Mina Archive Node along with the PostgreSQL RDBMS that stores the blockchain data.

Environment Variables

Configure the container behavior using these environment variables:

Variable Default Description
NETWORK_TYPE single-node Network topology type. Options: single-node (lightweight, fast startup) or multi-node (more realistic network simulation with multiple nodes)
PROOF_LEVEL full Cryptographic proof level. Options: full (generate real proofs, slower), none (skip proof generation, faster for testing)
LOG_LEVEL Trace Logging verbosity. Options: Trace, Debug, Info, Warn, Error
RUN_ARCHIVE_NODE true Run Archive Node and PostgreSQL. Set to false to disable archive functionality and reduce resource usage
SLOT_TIME 20000 Block slot time in milliseconds. Lower values produce blocks faster but may increase resource consumption
POSTGRES_USER postgres PostgreSQL username for archive database
POSTGRES_PASSWORD postgres PostgreSQL password for archive database
POSTGRES_DB archive PostgreSQL database name for archive data
ARCHIVE_API_CORS_ORIGIN * CORS_ORIGIN of the Archive-Node-API. Unset in the API means same-origin only; * allows any browser origin
ARCHIVE_API_ENABLE_INTROSPECTION true Allow GraphQL schema introspection on the Archive-Node-API
ARCHIVE_API_ENABLE_GRAPHIQL true Serve the GraphiQL playground at http://localhost:8282/
ARCHIVE_API_ENABLE_ZKAPP_COMMANDS_QUERY true Expose the zkappCommands range query of the Archive-Node-API
ARCHIVE_API_ENABLE_BLOCK_TRANSACTION_DETAILS true Include userCommands / zkappCommands / feeTransfers in blocks
ARCHIVE_API_RATE_LIMIT_MAX 0 Archive-Node-API requests per client IP per minute. 0 disables rate limiting
HARDFORK_IN (unset) Hard fork mode: the chain ends this long after the start (30m, 1h, 1800s; a bare number is minutes)
HARDFORK_AT (unset) Hard fork mode: the chain ends at this date (RFC 3339, e.g. 2026-12-01T14:00:00Z). Set this or HARDFORK_IN, not both
HARDFORK_TX_END_BEFORE 28 Hard fork mode: slots before the chain end from which transactions are rejected (1 to 29)
HARDFORK_GENESIS_DELTA 20 Hard fork mode: slots from the chain end to the postfork genesis, the restart window

The ARCHIVE_API_* variables map to the environment variables of Archive-Node-API 2.x, which is secure by default. The container opens them for local development.

Example with Custom Configuration

docker run --rm --pull=always -it \
  --env NETWORK_TYPE="single-node" \
  --env PROOF_LEVEL="none" \
  --env LOG_LEVEL="Info" \
  --env RUN_ARCHIVE_NODE="true" \
  --env SLOT_TIME="20000" \
  -p 3085:3085 \
  -p 5432:5432 \
  -p 8080:8080 \
  -p 8181:8181 \
  -p 8282:8282 \
  o1labs/mina-local-network:latest-lightnet

Disabling Archive Node

To prevent the Mina Archive Node and RDBMS from running (reduces memory usage):

docker run ... --env RUN_ARCHIVE_NODE="false" ...

Note: When Archive Node is disabled, Archive-Node-API won't be available.

Network Types

Single Node

A lightweight configuration running a single Mina Daemon that acts as block producer, snark worker, and seed node simultaneously.

docker run --rm --pull=always -it \
  --env NETWORK_TYPE="single-node" \
  --env PROOF_LEVEL="none" \
  --env LOG_LEVEL="Info" \
  --env RUN_ARCHIVE_NODE="true" \
  --env SLOT_TIME="20000" \
  -p 3085:3085 \
  -p 5432:5432 \
  -p 8080:8080 \
  -p 8181:8181 \
  -p 8282:8282 \
  o1labs/mina-local-network:latest-lightnet

Single Node Network Properties

Property Value
Transaction finality (k) 30 blocks
Slots per epoch 720
Block production ~20-40 seconds
Transactions per block 5-8
RAM consumption ~850-970 MB (after initial spike, if running < 2 hours)
Startup/sync time ~1-2 minutes

Single Node Exposed Ports

Port Service
3085 Mina Daemon GraphQL endpoint
5432 PostgreSQL RDBMS
8080 NGINX reverse proxy (recommended endpoint)
8181 Mina Accounts Manager
8282 Archive-Node-API

Single Node Services Topology

+-------------------+   +-------------------+
|                   |   |                   |
|  Mina             |   |  NGINX            |
|  multi-purpose    |   |  Reverse Proxy    |
|  Daemon           |   |                   |
|                   |   |                   |
+-------------------+   +-------------------+

+-------------------+   +-------------------+
|                   |   |                   |
|  PostgreSQL       |   |  Mina Accounts    |
|  RDBMS (optional) |   |  Manager          |
|                   |   |                   |
+-------------------+   +-------------------+

+-------------------+   +-------------------+
|                   |   |                   |
|  Archive-Node-API |   |  Mina Archive     |
|  (optional)       |   |  Node (optional)  |
|                   |   |                   |
+-------------------+   +-------------------+

Multi-Node

A more realistic network simulation with multiple independent Mina Daemon processes including seed nodes, block producers (whales and fish), snark coordinator, and snark worker.

docker run --rm --pull=always -it \
 --env NETWORK_TYPE="multi-node" \
 --env PROOF_LEVEL="none" \
 --env LOG_LEVEL="Info" \
 --env RUN_ARCHIVE_NODE="true" \
 --env SLOT_TIME="20000" \
 -p 4001:4001 \
 -p 4006:4006 \
 -p 5001:5001 \
 -p 5432:5432 \
 -p 6001:6001 \
 -p 8080:8080 \
 -p 8181:8181 \
 -p 8282:8282 \
 o1labs/mina-local-network:latest-lightnet

Multi-Node Network Properties

Property Value
Transaction finality (k) 30 blocks
Slots per epoch 720
Block production ~20-40 seconds
Transactions per block 5-8
RAM consumption ~5.5-6+ GB
Startup/sync time ~4-6 minutes

Multi-Node Exposed Ports

Port Service
4001 Whale #1 Mina Daemon GraphQL endpoint
4006 Whale #2 Mina Daemon GraphQL endpoint
5001 Fish #1 Mina Daemon GraphQL endpoint
5432 PostgreSQL RDBMS
6001 Non block-producing node #1 GraphQL endpoint
8080 NGINX reverse proxy (routes to Whale #2)
8181 Mina Accounts Manager
8282 Archive-Node-API

Multi-Node Services Topology

+-------------------+   +-------------------+
|                   |   |                   |
|  NGINX            |   |  Mina             |
|  Reverse Proxy    |   |  Seed node 1      |
|                   |   |                   |
+-------------------+   +-------------------+

+-------------------+   +-------------------+   +-------------------+
|                   |   |                   |   |                   |
|  Mina             |   |  Mina             |   |  Mina             |
|  Block producer   |   |  Block producer   |   |  Block producer   |
|  Whale 1          |   |  Whale 2          |   |  Fish 1           |
|                   |   |                   |   |                   |
+-------------------+   +-------------------+   +-------------------+

+-------------------+   +--------------------+   +-------------------+
|                   |   |                    |   |                   |
|  Mina             |   |  Mina              |   |  Mina             |
|  Non BP           |   |  Snark coordinator |   |  Snark worker     |
|  Node 1           |   |                    |   |                   |
|                   |   |                    |   |                   |
+-------------------+   +--------------------+   +-------------------+

+-------------------+   +-------------------+
|                   |   |                   |
|  PostgreSQL       |   |  Mina Accounts    |
|  RDBMS (optional) |   |  Manager          |
|                   |   |                   |
+-------------------+   +-------------------+

+-------------------+   +-------------------+
|                   |   |                   |
|  Archive-Node-API |   |  Mina Archive     |
|  (optional)       |   |  Node (optional)  |
|                   |   |                   |
+-------------------+   +-------------------+

Hard Fork Mode

With HARDFORK_IN or HARDFORK_AT set, the network goes through a hard fork: its chain ends at that time, and the network starts again on a new chain that keeps every account, with its balance, nonce, zkApp state and verification key. The fork is to the image's own Mina version, so it is the cheapest way to test that an app keeps working across a hard fork. Without these variables nothing changes.

docker run --rm --pull=always -it \
  --env NETWORK_TYPE="single-node" \
  --env PROOF_LEVEL="none" \
  --env HARDFORK_IN="30m" \
  -p 8080:8080 -p 8181:8181 -p 8282:8282 \
  o1labs/mina-local-network:latest-lightnet

minimina plans the fork when it creates the network, and the container drives it: once the chain has ended, it gets the fork config from the daemons (minimina network hardfork prepare), stops the network, upgrades the archive database and starts the network on the postfork chain (minimina network hardfork apply).

Phases

With the default slot time (20 s) and the defaults of HARDFORK_TX_END_BEFORE and HARDFORK_GENESIS_DELTA:

From Phase Blocks Transactions GraphQL
The start prefork yes yes yes
28 slots (9 min 20 s) before the chain end tx-end yes, without transactions rejected yes
The chain end (HARDFORK_IN after the start, or HARDFORK_AT) chain-end no rejected yes, but 503 while the daemons restart
20 slots (6 min 40 s) after the chain end fork-genesis yes, on the postfork chain yes yes
  • Earliest fork: transactions must be accepted for at least 10 minutes after the start, so with the defaults HARDFORK_IN must be at least 20m. With HARDFORK_TX_END_BEFORE=5 it can be 12m.
  • During the restart, GraphQL on port 8080 answers 503 with the fork's status as JSON instead of refusing the connection.
  • The accounts manager restarts with the network: accounts acquired from it before the fork are released. Acquire them again after the fork.
  • k is 30 in hard fork mode, the k of the lightnet profile, also for devnet images. Without the fork, the devnet profile's own k (290) stays.
  • Multi-node with the archive node can fail to prepare the fork: the archive toolbox of Mina 4.0.4 can pick a block that is not on the best chain (fixed by MinaProtocol/mina#19991, not in a release yet). Single-node has one block producer, so it is not affected.
  • docker restart starts a new network, as without the fork.

Following the Fork

The container log has a banner for each phase and step:

==> [hardfork] PREFORK  slot 1  2026-11-23T16:11:53Z
    transactions are accepted until slot 32 (2026-11-23T16:21:55.431028+00:00)
    the chain ends at slot 60 (2026-11-23T16:31:15.431028+00:00)
    the postfork chain starts at slot 80 (2026-11-23T16:37:55.431028+00:00)
docker logs <container> 2>&1 | grep -A3 '^==> \[hardfork\]'

http://localhost:8080/hardfork/ is a status page: the phase, the countdown to the next one, the fork's steps (planned, prepared, applied) and the sync status and height of the daemon behind /graphql. It updates itself every 5 seconds.

http://localhost:8080/hardfork/status.json has the fork's status, that of minimina network hardfork status: the phase, the state of the fork (planned, prepared, applied), the current slot, the slot and time of slot_tx_end, slot_chain_end and fork_genesis, and the next phase with the seconds until it.

To wait for a phase of the fork, and then for the daemon to be synced, from a script or CI job:

docker exec <container> /root/wait-for-network.sh 8080 --phase fork-genesis

The phase is prefork, tx-end, chain-end or fork-genesis; it returns once the network is in that phase or a later one. With fork-genesis it also waits for the fork to be applied, and fails if it is not applied 10 minutes after the postfork genesis.

To test the hard fork mode of an image (about 30 minutes):

./scripts/test-hardfork.sh test-local/mina-local-network:4.0.4-lightnet

Connecting to the Network

GraphQL Endpoint

Connect your application to the Mina network using the GraphQL endpoint:

http://127.0.0.1:8080/graphql

This endpoint goes through NGINX reverse proxy with proper CORS headers, making it compatible with browser-based applications.

PostgreSQL Database

Connect to the archive database for querying historical blockchain data:

postgresql://postgres:postgres@127.0.0.1:5432/archive

Using with o1js

import { Mina } from 'o1js';

const network = Mina.Network('http://127.0.0.1:8080/graphql');
Mina.setActiveInstance(network);

Waiting for Network Readiness

The network needs to reach a synchronized state before it can process transactions. You can poll the GraphQL endpoint or use the wait-for-mina-network GitHub Action in CI/CD pipelines.

Example health check:

curl -s http://127.0.0.1:8080/graphql \
  -H 'Content-Type: application/json' \
  -d '{"query": "{ syncStatus }"}' | jq -r '.data.syncStatus'

Wait until the response is SYNCED.

Logs

Logs are stored inside the container at:

# Every process of the network (minimina)
/root/.minimina/lightnet/logs/*.log

# Links to them where they were before
/root/logs/*.log
/root/.mina-network/mina-local-network-2-1-1/nodes/*/log.txt   # multi-node

The container's log (docker logs) follows all of them.

Mount a volume to persist logs:

docker run ... --mount "type=bind,source=/tmp,dst=/root/logs" ...

Mina Accounts Manager

The Mina Accounts Manager automates how users retrieve account information. Useful for parallel automated tests where each test needs isolated accounts.

API Endpoints

Method Endpoint Description
GET /acquire-account Get an unused account from the pool
PUT /release-account Return an account to the pool
GET /list-acquired-accounts List all currently acquired accounts
PUT /lock-account Lock an account on the daemon
PUT /unlock-account Unlock an account on the daemon

Acquire Account

curl http://127.0.0.1:8181/acquire-account
# Response: { "pk": "B62q...", "sk": "EKE..." }

Query parameters:

  • isRegularAccount=<boolean> (default: true) - Set to false for zkApp accounts
  • unlockAccount=<boolean> (default: false) - Unlock account on acquisition

Release Account

curl -X PUT http://127.0.0.1:8181/release-account \
  -H 'Content-Type: application/json' \
  -d '{ "pk": "B62q...", "sk": "EKE..." }'

List Acquired Accounts

curl http://127.0.0.1:8181/list-acquired-accounts
# Response: [ { "pk": "...", "sk": "..." }, ... ]

GitHub Actions Integration

Service Container Example

jobs:
  my-job:
    services:
      mina-local-network:
        image: o1labs/mina-local-network:latest-lightnet
        env:
          NETWORK_TYPE: 'single-node'
          PROOF_LEVEL: 'none'
          LOG_LEVEL: 'Info'
        ports:
          - 3085:3085
          - 5432:5432
          - 8080:8080
          - 8181:8181
          - 8282:8282
        volumes:
          - /tmp:/root/logs
    steps:
      - name: Wait for Mina Network readiness
        uses: o1-labs/wait-for-mina-network-action@v1
        with:
          mina-graphql-port: 8080

      - name: Run tests
        run: npm test

      - name: Upload Mina logs
        uses: actions/upload-artifact@v3
        if: always()
        with:
          if-no-files-found: ignore
          name: mina-logs
          path: /tmp/*.log
          retention-days: 5

Image Tags

Image tags follow this naming convention:

o1labs/mina-local-network:<mina-version>-<profile>      # a Mina release (recommended: pin it)
o1labs/mina-local-network:latest-<profile>              # alias of the newest stable release
o1labs/mina-local-network:next-<profile>                # alias of the newest pre-release (alpha/beta)

Examples:

  • 4.0.4-lightnet - Mina stable release 4.0.4 with lightnet profile (no proofs, fast)
  • 4.0.4-devnet - Mina stable release 4.0.4 with devnet profile (full proofs)
  • latest-lightnet - Newest stable release with lightnet profile (alias of the newest <mina-version>-lightnet)
  • next-lightnet - Newest pre-release with lightnet profile, for example the first builds of a post-hardfork Mina version. Published only while such a pre-release exists.

Legacy aliases, kept so that existing setups keep working:

  • master-latest-<profile> - Same image as latest-<profile>, updated with every stable release.
  • compatible-latest-<profile> - Used to track the compatible branch nightlies. zkApp CLI 0.23.0 runs it by default (zk lightnet start), so it follows the stable releases, like latest-<profile>, until a zkApp CLI release that runs latest-<profile> (o1-labs/zkapp-cli#790) is out. In your own setups, use latest-<profile> or a pinned <mina-version>-<profile>.
  • develop-latest-<profile> - Former nightly build of the develop branch. Nightly images are not published anymore; the tag is stale (May 2026). Do not use it.

Where:

  • Version prefix (4.0.4, 4.1.0-beta1), latest or next: A Mina release from the stable or unstable apt repo
  • Profile suffix (lightnet, devnet): The Mina profile the daemon runs with
    • lightnet: Proof level set to none, faster for testing
    • devnet: Full proof generation

Architectures: the 4.0.4-<profile>, latest-<profile>, master-latest-<profile> and compatible-latest-<profile> images are built for amd64 and arm64 (Apple silicon runs them natively). Older release images, for example 4.0.2-<profile>, are amd64 only, because the stable apt repo has no arm64 debs for those releases. On an arm64 computer, pull them with --platform linux/amd64 (or DOCKER_DEFAULT_PLATFORM=linux/amd64); Docker runs them in emulation.

Building Images

Prerequisites

  • Docker with buildx support

Build All Images

Builds the devnet and the lightnet image of a stable Mina release (tags master-latest-<profile>):

./scripts/build-all.sh \
  --archs "amd64" \
  --mina-release stable \
  --target-branches "master" \
  --mina-deb-version "4.0.4-c9e2eac" \
  --docker-hub-user "o1labs"

Build Script Options

Option Description
--archs Target architectures (comma-separated: amd64, arm64)
--mina-release Release type: stable, alpha or beta. nightly is still accepted by the scripts, but no images are published from nightlies anymore
--target-branches Mina branches to build (comma-separated)
--archive-api-version Version of Archive-Node-API
--accounts-manager-version Version of Mina Accounts Manager
--docker-hub-user Docker Hub username
--docker-scripts-dir Path to this repository
--skip-push Build without pushing to Docker Hub
--no-cache Disable Docker build cache
--extra-docker-suffix Extra suffix for image tags
--mina-deb-version Exact Mina deb version to install (e.g. 4.0.2-84b8d96). Default: newest in the apt component

Build Single Image

The stable and unstable apt repos have no lightnet variant deb, so the lightnet image installs the devnet debs and selects the lightnet profile at runtime (--mina-runtime-profile, Mina >= 4.0.2). --tag accepts a comma-separated list:

./scripts/build-image.sh \
  --archs "amd64" \
  --mina-release stable \
  --mina-deb-version "4.0.4-c9e2eac" \
  --mina-profile devnet \
  --mina-runtime-profile lightnet \
  --proof-level none \
  --docker-user "o1labs" \
  --tag "4.0.4-lightnet,latest-lightnet,master-latest-lightnet"

Publish a Stable Release

The manual GitHub Actions workflow .github/workflows/build-release.yml builds and pushes both images of a stable release, plus the latest-<profile>, master-latest-<profile> and compatible-latest-<profile> aliases:

gh workflow run build-release.yml --ref develop \
  -f mina_version=4.0.4 -f mina_deb_version=4.0.4-c9e2eac -f archs=amd64,arm64

It pushes without testing the images: test the branch first (test.yml, and test-hardfork.sh for a change to the hard fork mode), and keep the current digests of the tags it moves to roll back with docker buildx imagetools create.

Publish a Pre-Release

The manual GitHub Actions workflow .github/workflows/build-prerelease.yml builds and pushes both images of a Mina pre-release from the alpha or beta component of the unstable apt repo, plus the next-<profile> alias:

gh workflow run build-prerelease.yml --ref develop \
  -f mina_release=beta -f mina_version=4.1.0-beta1 -f mina_deb_version=4.1.0-beta1-abc1234 -f archs=amd64

About

Building and publishing primitives for lightweight Mina network Docker images

Resources

Stars

1 star

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages