Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Docker compose启动geth init和geth挖掘?_Docker_Docker Compose_Ethereum_Geth - Fatal编程技术网

如何使用Docker compose启动geth init和geth挖掘?

如何使用Docker compose启动geth init和geth挖掘?,docker,docker-compose,ethereum,geth,Docker,Docker Compose,Ethereum,Geth,我想用Docker创建专用以太坊网络。我已经准备好了genesis文件,所以我需要geth init genesis.json,然后像geth--mine…一样开始挖掘。我可以用脚本(比如这里:和): 由于这似乎是两步流程,我如何使用Docker compose完成它 如果我重写挖掘服务的命令:,我应该写什么?如果我只写geth init,那么它将不会开始挖掘。如果我尝试加入并编写命令:init genesis.json--我的…它会伤害: version: "3" services: e

我想用Docker创建专用以太坊网络。我已经准备好了genesis文件,所以我需要
geth init genesis.json
,然后像
geth--mine…
一样开始挖掘。我可以用脚本(比如这里:和):

由于这似乎是两步流程,我如何使用Docker compose完成它

如果我重写挖掘服务的
命令:
,我应该写什么?如果我只写
geth init
,那么它将不会开始挖掘。如果我尝试加入并编写
命令:init genesis.json--我的…
它会伤害:

version: "3"

services:
  eth_miner:
    image: ethereum/client-go:v1.7.3
    ports:
      - "8545:8545"
    volumes:
      - ${DATA_ROOT}:/root/.ethereum
      - ${GENESIS_FILE}:/opt/genesis.json
    command: init /opt/genesis.json --rpc --rpcaddr=0.0.0.0 --rpcapi=db,eth,net,web3,personal --rpccorsdomain "*" --nodiscover --cache=512 --verbosity=4 --mine --minerthreads=3 --networkid 15 --etherbase="${ETHERBASE}" --gasprice=${GASPRICE}
日志:


最好的选择是创建一个shell脚本,该脚本执行初始化,然后运行geth,应该如下所示:

#!/bin/bash
if [ ! -d /root/.ethereum/keystore ]; then
    echo "/root/.ethereum/keystore not found, running 'geth init'..."
    geth init /opt/genesis.json
    echo "...done!"
fi

geth "$@"
和docker-compose.yaml:

version: "3"

services:
  eth_miner:
    image: ethereum/client-go:v1.7.3
    ports:
      - "8545:8545"
    volumes:
      - ${DATA_ROOT}:/root/.ethereum
      - ${GENESIS_FILE}:/opt/genesis.json
      - ./init-script.sh:/root/init-script.sh
    entrypoint: /root/init-script.sh
    command: --bootnodes=$BOOTNODE_URL $RPC_ARG --cache=512 --verbosity=4 --maxpeers=3 ${@:2}

最好的选择是创建一个shell脚本,该脚本执行初始化,然后运行geth,应该如下所示:

#!/bin/bash
if [ ! -d /root/.ethereum/keystore ]; then
    echo "/root/.ethereum/keystore not found, running 'geth init'..."
    geth init /opt/genesis.json
    echo "...done!"
fi

geth "$@"
和docker-compose.yaml:

version: "3"

services:
  eth_miner:
    image: ethereum/client-go:v1.7.3
    ports:
      - "8545:8545"
    volumes:
      - ${DATA_ROOT}:/root/.ethereum
      - ${GENESIS_FILE}:/opt/genesis.json
      - ./init-script.sh:/root/init-script.sh
    entrypoint: /root/init-script.sh
    command: --bootnodes=$BOOTNODE_URL $RPC_ARG --cache=512 --verbosity=4 --maxpeers=3 ${@:2}

docker-compose.yml中的选项“command”只是将“/root/init-script.sh--bootnodes=…”作为参数传递给docker-entrypoint.sh。恐怕入口点可以是
geth
。如果是,那么它将不起作用(除非我们也可以覆盖入口点cmd)。我的错误,只是编辑了答案。我忘了修改入口点。感谢编辑,我已经检查了入口点是否真的是
geth
,所以我们也需要覆盖它。我相信在一般情况下运行这样的脚本可以解决问题。在这个特殊的例子中,我得到了
/root/init script.sh
/opt/init script.sh
的“权限被拒绝”,运行chmod+x init-script.sh docker-compose.yml中的选项“command”只需将“/root/init-script.sh--bootnodes=…”作为参数传递给docker-entrypoint.sh。恐怕入口点可以是
geth
。如果是,那么它将不起作用(除非我们也可以覆盖入口点cmd)。我的错误,只是编辑了答案。我忘了修改入口点。感谢编辑,我已经检查了入口点是否真的是
geth
,所以我们也需要覆盖它。我相信在一般情况下运行这样的脚本可以解决问题。在这种特殊情况下,我得到了
/root/init script.sh
/opt/init script.sh
运行chmod+x init-script.sh的“权限被拒绝”