本文以 testnet 为例,mainnet 只需要修改对应的参数
拉取 Docker 镜像
$ docker pull hayeah/qtumportal
修改启动配置
容器里启动配置文件为 /usr/local/bin/qtumd-launch
,我们需要修改一些启动参数,再挂载上去
-
-rpcallowip=$QTUM_RPC_ALLOWIP
: 默认的 RPC 白名单为 "172.17.0.0/16",禁止了远程访问,修改为读取环境变量 -
-txindex=1
: 开启事务索引(如果需要扫描区块数据,要开启此项配置)
创建启动文件
$ vim /docker/qtum-testnet/qtumd-launch
#!/bin/sh
set -e
case $QTUM_NETWORK in
local|regtest)
SELECT_NETWORK=-regtest
;;
test|testnet)
SELECT_NETWORK=-testnet
;;
main|mainnet)
SELECT_NETWORK=
;;
*)
echo "Unknown network: $QTUM_NETWORK"
exit 1
esac
mkdir -p $QTUM_DATADIR
exec qtumd ${SELECT_NETWORK} \
-rpcbind=0.0.0.0:3889 -rpcallowip=$QTUM_RPC_ALLOWIP \
-datadir=$QTUM_DATADIR \
-logevents \
-rpcuser=$QTUM_RPC_USER -rpcpassword=$QTUM_RPC_PASS \
-txindex=1 \
-printtoconsole
添加可执行权限
$ chmod +x /docker/qtum-testnet/qtumd-launch
启动容器
测试网络:QTUM_NETWORK=testnet
主网:QTUM_NETWORK=mainnet
$ docker run -d \
--name qtum-testnet \
--restart always \
-v /docker/qtum-testnet:/data \
-v /docker/qtum-testnet/qtumd-launch:/usr/local/bin/qtumd-launch \
-e "QTUM_RPC_ALLOWIP=0.0.0.0/0" \
-e "QTUM_DATADIR=/data" \
-e "QTUM_NETWORK=testnet" \
-e "QTUM_RPC_USER=test" \
-e "QTUM_RPC_PASS=test1234" \
-p 13889:3889 \
hayeah/qtumportal
测试 qtum-cli
$ docker exec -it qtum-testnet qtum-cli -testnet -rpcuser=test -rpcpassword=test1234 -rpcport=3889 listaccounts
网友评论