This procedure demonstrates how to run a local testnet node using Docker images.
This procedure focuses on Unix-like operating systems (Linux and MacOS). This procedure has not been tested on Windows.
Running a node has no specialized hardware requirements. Users have been successful in running nodes on Raspberry Pi boards and other system-on-chip architectures. In order to complete this procedure, you must have the following software installed on the node host machine:
In order for the API node services to work correctly, you must configure any network firewall rules to allow traffic on the ports discussed in this section. The details of network and firewall configuration are highly specific to your machine and network, so a detailed example isn't provided.
The following ports must open on the host machine:
- stacks-blockchain (open to
These egress ports are for syncing
stacks-blockchain and Bitcoin headers. If they're not open, the sync will fail.
Step 1: Initial setup
In order to run the testnet node, you must download the Docker images and create a directory structure to hold the persistent data from the services. Download and configure the Docker images with the following commands:
docker pull blockstack/stacks-blockchain
Create a directory structure for the service data with the following command:
mkdir -p ./stacks-node/persistent-data/stacks-blockchain/testnet && cd stacks-node
Step 2: Running Stacks blockchain
stacks-blockchain container with the following command:
docker run -d --rm \
--name stacks-blockchain \
-v $(pwd)/persistent-data/stacks-blockchain/testnet:/root/stacks-node/data \
-p 20443:20443 \
-p 20444:20444 \
You can verify that the container
stacks-blockchain is running with the command:
docker ps --filter name=stacks-blockchain
Step 3: Verifying the services
The initial header sync can take several minutes, until this is done the following commands will not work.
To verify the
stacks-blockchain burn chain header sync progress:
docker logs stacks-blockchain
The output should be similar to the following:
INFO [1626290705.886954] [src/burnchains/bitcoin/spv.rs:926] [main] Syncing Bitcoin headers: 1.2% (8000 out of 2034380)
INFO [1626290748.103291] [src/burnchains/bitcoin/spv.rs:926] [main] Syncing Bitcoin headers: 1.4% (10000 out of 2034380)
INFO [1626290776.956535] [src/burnchains/bitcoin/spv.rs:926] [main] Syncing Bitcoin headers: 1.7% (12000 out of 2034380)
To verify the
stacks-blockchain tip height is progressing use the following command:
curl -sL localhost:20443/v2/info | jq
If the instance is running you should receive terminal output similar to the following:
"server_version": "stacks-node 220.127.116.11.0-rc1 (develop:7b6d3ee+, release build, linux [x86_64])",
Stopping the testnet node
Use the following command to stop the local testnet node:
docker stop stacks-blockchain