In this tutorial, we will adopt, set up, and run a Hiero node locally using Docker. By the end of this tutorial, you'll be equipped to run a Hiero local node and generate keys, allowing you to test your projects and deploy projects in your local environment.
Prerequisites
>= v14.x
>= v6.14.17**
Minimum 16GB RAM
>= v20.10.x
>= v2.12.3
Have Docker running on your machine with the correct configurations.
Ensure the VirtioFS file sharing implementation is enabled in the docker settings.
Ensure the following configurations are set at minimum in Docker Settings -> Resources and are available for use:
CPUs: 6
Memory: 8GB
Swap: 1 GB
Disk Image Size: 64 GB
Ensure the Allow the default Docker sockets to be used (requires password) is enabled in Docker Settings -> Advanced.
Note: The image may look different if you are on a different version
Note
**Local node can be run using Docker, NPM, or on CDEs but we will use Docker for this tutorial.are the installation steps for NPM.
Table of Contents
Start Your Local Network
Open a new terminal and navigate to your preferred directory where your Hiero Local Node project will live. Run the following command to clone the repo and install dependencies to your local machine:
git clone https://github.com/hiero-ledger/hiero-local-node.git
cd hiero-local-node
npm install
For Windows users: You will need to update the file endings of compose-network/mirror-node/init.sh by running this in WSL:
dos2unix compose-network/mirror-node/init.sh
Ensure Docker is installed and open on your machine before running this command to get the network up and running:
// starts and generates the first 30 accounts
npm run start -- -d
or
// will start local node but will not generate the first 30 accounts
docker compose up -d
Generate Keys
To generate accounts with random private keys, run the generate-accounts command. Specify the number of accounts generated by appending the number to the hedera generate-account command. For example, to generate 5 accounts, run hedera generate-accounts 5.
Please note: Since the first 10 accounts generated are with predefined private keys, if you need 5 generated with random keys, you will run hedera start 15. The same rule applies when you use the hedera generate-accounts command.
Grab any of the account private keys generated from the Alias ECDSA keys Accounts list. This will be used as the LOCAL_NODE_OPERATOR_PRIVATE_KEY environment variable value in your .env file of your project.
Stop Your Local Network
To stop your local node, you can run the hedera stop command. If you want to keep any files created manually in the working directory, please save them before executing this command.
hedera stop
Stopping the network...
Stopping the docker containers...
Cleaning the volumes and temp files...
Alternatively, run docker compose down -v; git clean -xfd; git reset --hard to stop the local node and reset it to its original state.
docker compose down -v; git clean -xfd; git reset --hard