Skip to content

Run With Docker

csquan edited this page Jun 4, 2020 · 21 revisions

Run in docker

Simple and fast setup of CocosBcx Node on Docker is also available.

Install Dependencies

  • Docker Docker 17.05 or higher is required
  • docker-compose version >= 1.10.0
  • Curl (any version you like)
  • Python (any version you like)

Docker Requirement

  • CPU: 4 cores or more
  • Memory: 16GB or more
  • Disk: 500GB or more
  • Network: access to Internet with port tcp: 8049,8050

Start the node

By default, /mnt/witness is going to mount as the data volume, you might change the path to suit your needs. We refer to $PREFIX hereafter.

Using boot script

You can automatically deploy a full node with the following command

curl https://raw.githubusercontent.com/Cocos-BCX/cocos-bcx-node-bin/master/fullnode/mainnet/v1.1.4.1/build_chain.sh | bash

To start,stop or restart the node,you could execute follow command:

## start
docker start witness
## stop
docker stop witness
## restart
docker restart witness

Manually

Data

Warning:Make sure $PREFIX is "/mnt/witness". For some users who cannot download build.sh,should first create dir wintess/config under mnt,then download config.ini and genesis.json under witness/config. If you have already run previous version of witness, make sure the old data has been purged or just backup data and then remove it:

rm -rf $PREFIX/config

or

tar -cvzf data.tar.gz  $PREFIX
rm -rf $PREFIX/config

Config

## get genesis and config
## Attention:if you have add any config option in config file,just copy it back
curl -fsSL "https://raw.githubusercontent.com/Cocos-BCX/cocos-bcx-node-bin/master/fullnode/mainnet/v1.0.9/config/genesis.json" -o $PREFIX/config/genesis.json
## get witness config
curl -fsSL "https://raw.githubusercontent.com/Cocos-BCX/cocos-bcx-node-bin/master/fullnode/mainnet/v1.0.9/config/config.ini" -o $PREFIX/config/config.ini

Start node docker container

docker pull  cocosbcx/cocos-mainnet:latest
docker run -itd --restart=always \
--name witness -v $PWD/config:/root/witness/config \
-v $PWD/COCOS_BCX_DATABASE:/root/witness/COCOS_BCX_DATABASE \
-v $PWD/logs:/root/witness/logs -p 8049:8049 \
-p 8050:8050  cocosbcx/cocos-mainnet:latest

Get chain info

wscat -c ws://127.0.0.1:8090

Upgrade the node

Pull image

docker  pull cocosbcx/cocos-mainnet:latest

Remove outdated witness

docker stop witness && docker rm witness

If you don't need witness afterwards, you can stop the witness service using

docker-compose stop witness
docker-compose start witness
Clone this wiki locally