Docker
A Docker container allows you to easily run a node without depending on the platform it is running on. This method should only be used if you already have experience with Docker containers.
Installation
Start by installing docker: How to install Docker on Ubuntu
Create a local directory for the chain storage data and a dedicated user:
sudo mkdir /var/lib/astar
sudo useradd --no-create-home --shell /usr/sbin/nologin astar
sudo chown astar:astar /var/lib/astar
Start Docker node
This guide goes over the process of starting a container with both WS and RPC endpoints. For a single type of endpoint, simply remove the unnecessary port and command.
Launch the docker node in detached mode:
Make sure to change the {NODE_NAME}
- Astar
- Shiden
- Shibuya
docker run -d \
--name astar-container \
-u $(id -u astar):$(id -g astar) \
-p 30333:30333 \
-p 9944:9944 \
-v "/var/lib/astar/:/data" \
staketechnologies/astar-collator:latest \
astar-collator \
--pruning archive \
--rpc-cors all \
--name {NODE_NAME} \
--chain astar \
--base-path /data \
--rpc-external \
--rpc-methods Safe \
--rpc-max-request-size 1 \
--rpc-max-response-size 1 \
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0'
docker run -d \
--name shiden-container \
-u $(id -u astar):$(id -g astar) \
-p 30333:30333 \
-p 9944:9944 \
-v "/var/lib/astar/:/data" \
staketechnologies/astar-collator:latest \
astar-collator \
--pruning archive \
--rpc-cors all \
--name {NODE_NAME} \
--chain shiden \
--base-path /data \
--rpc-external \
--rpc-methods Safe \
--rpc-max-request-size 1 \
--rpc-max-response-size 1 \
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0'
docker run -d \
--name shibuya-container \
-u $(id -u astar):$(id -g astar) \
-p 30333:30333 \
-p 9944:9944 \
-v "/var/lib/astar/:/data" \
staketechnologies/astar-collator:latest \
astar-collator \
--pruning archive \
--rpc-cors all \
--name {NODE_NAME} \
--chain shibuya \
--base-path /data \
--rpc-external \
--rpc-methods Safe \
--rpc-max-request-size 1 \
--rpc-max-response-size 1 \
--telemetry-url 'wss://telemetry.polkadot.io/submit/ 0'
Test the node health via the RPC port with this command:
curl -H "Content-Type: application/json" --data '{ "jsonrpc":"2.0", "method":"system_health", "params":[],"id":1 }' localhost:9944
Next steps
In any case, wait for the chain to be fully synchronized by checking the node log.
How the archive node will be used will largely determine what steps to follow next:
- If accessing the node publicly, running an nginx server is the recommended option.
- If the dApp is running on the same server as the node, then it can be accessed directly with the
localhost
address. This setup is recommended for testing purposes only. - If running the node locally for testing purposes, switch networks in Polkadot.js portal to explore the chain:
Extra Operations
Get node logs
To obtain the last 100 lines from the node logs, use the following command:
docker logs -f -n 100 $(docker ps -aq --filter name="{CHAIN}-container")
replacing {CHAIN}
with astar
, shiden
, or shibuya
eg.
docker logs -f -n 100 $(docker ps -aq --filter name="astar-container")