In this tutorial, we will walk through the process of setting up a local node on Celo using Docker. By following these steps, you will be able to run a Celo node on your computer. Let’s get started!
Before you begin, make sure you have Docker installed on your computer. Docker allows you to create and manage containers, which will be used to run the Celo node.
Open a new terminal and create a new folder to contain your Docker container. Navigate into the folder using the terminal.
mkdir celo-node cd celo-node
Export a variable with the Celo Alpha Horse node image and pull it using Docker.
export CELO_IMAGE=us.gcr.io/celo-org/celo-node:alpha-horse docker pull $CELO_IMAGE
Now, let’s run the Celo node image with the following parameters:
docker run -it --restart always --stop-timeout 300 --name celo-node -p 8545:8545 -v $PWD:/root/celo -e CELO_IMAGE=$CELO_IMAGE --entrypoint /bin/bash $CELO_IMAGE
This command runs the image in interactive mode, maps port 8545 in the container to port 8545 on your host machine, and mounts the current working directory as a volume in the container at
/root/celo. This allows the node to persist data across container restarts.
Inside the container, you can configure the Celo node according to your requirements. Here are some common configurations:
Set the node to sync with the network in light mode and set the logging level to level 3 (info).
celo --nodedir /root/celo init light --verbosity 3
Enable the HTTP RPC server to listen for connections on all available network interfaces.
celo --nodedir /root/celo run --networkid mainnet --rpc --rpcaddr 0.0.0.0
Specify which APIs to enable for the HTTP RPC server. For example, to enable all APIs:
celo --nodedir /root/celo run --networkid mainnet --rpc --rpcaddr 0.0.0.0 --rpcapi eth,net,web3,debug,admin,personal,txpool
Set the node’s data directory to
/root/celo (already configured in the Docker volume).
If you want to allow insecure unlocking of the node (for development purposes), use the following flag:
celo --nodedir /root/celo run --networkid mainnet --rpc --rpcaddr 0.0.0.0 --insecure-unlock
You should now see your new container running in the Docker UI. Switch back to the command-line interface (CLI) for the next steps.
To create a new account using your local node, run the following command inside the container:
celo --nodedir /root/celo account new
Save the generated password and take note of the address of your new account.
If you want to access the keystore file for your new account, you can go to the Docker container files tab in the Docker UI and navigate to the appropriate path.
To stop the Celo node, run the following command:
docker stop celo-node
Congratulations! You have successfully set up a Celo local node on your computer using Docker. Feel free to explore further and dive into the world of Celo blockchain development. See you on the next tutorial!