Running Pchain in Docker
Last updated
Was this helpful?
Last updated
Was this helpful?
One of the quickest ways to get Pchain up and running on your machine is by using Docker.
If your PC's operating system is Ubuntu, you can get docker as follows:
To see more details, you can see the .
Note: To install Docker CE, you need the 64-bit version of one of these Ubuntu versions:
Bionic 18.04 (LTS)
Xenial 16.04 (LTS)
Trusty 14.04 (LTS)
Running docker requires a 64-bit operating system, win7 or higher, and supports " Hardware Virtualization Technology", and "virtualization" is available.
To Run Pchain on dockers, you will make a Pchain docker image from Dockerfile
as follows from within a pchain folder:
You can check the image status by:
If the Pchain image has been built correctly, you can find an image called pchain
and the Tag
is latest
.
When the Pchain's docker image has been built, you can start Pchian in docker:
And you can see the containers status:
To run a single-node Pchain in docker, execute docker run -it pchain
. And create accounts with a specified balance, will generate eth_genesis.json:
Generate the Pchain genesis.json with epoch/reward scheme parameters:
to start the node:
You can deploy multiple nodes through docker in order to test jobs, smart contracts and child chains.
Add an ordinary node
Start another docker container, build a fresh node('B') but don't start it (not run the ./run.sh
).
Here are the steps to make the new node ('B') join the existing node ('A'):
stop Pchain on A
add the peer entry,
add B's ip:port(say 172.17.0.3:46656) to A's config.toml
,
add A's ip:port(say 172.17.0.2:46656) to B's config.toml
. Then, A's config.toml should look like:
Copy A's genesis.json
and eth_genesis.json
to B, make their genesis.json keep the same, therefore the validators are the same between A and B.
Add A's enode
to B, you can get A's enode
by RPC command as follows:
Run Pchain on A and B (order is not relevant). After they are connected, B should start to synchronize blocks from A, and they will have the same blockchain behaviors when synchronization is complete.
Add a validator node
In order to add a validator node, there must be existing validators.
Start a new container from Pchain image, add a new node ('C') to the existing network but don't start it (not run the ./run.sh
).
Pick one validator (node 'A'), add C's pub-key (the long hex-string of pub_key
part in /path/to/priv_validator.json
) to A's validators
part in A's /path/to/genesis.json
. then A's validators"
part in genesis.json
should look like:
Important: Make sure C's amount is smaller than 1/2 of the sum of all other validators' amount in order to maintain fault-tolerant consensus
Copy A's genesis.json
and eth_genesis.json
to all other nodes within the network, including C.
Stop all nodes within the network.
Start all nodes with C the last one to start.
Extension: This should work for batch-addition of new validators.
Multi-node automated deployment
openssh-server
net-tools
curl
are installed in images. And all operation commands are contained in add_node.sh
. You might execute this command step by step but not in one time.
You can find the install package on the . If you want to run docker on windows, DO NOT use windows containers but use Linux containers. And make sure the Virtualization Technology is enabled. To see more details, you can see the and .
Note: For more information, see .