美文网首页Hyperledger
如何使用Docker快速启动EOSIO环境

如何使用Docker快速启动EOSIO环境

作者: 假装在去天使之城的路上 | 来源:发表于2018-07-22 21:18 被阅读14次

EOSIO构架

EOSIO主要包括了:

  • nodeos (node + eos = nodeos) - the core EOSIO node daemon that can be configured with plugins to run a node. Example uses are block production, dedicated API endpoints, and local development.
    EOSIO核心后台进程。可以通过设置,来运行一个node。例如:区块链产品,专用API,本地开发。

  • cleos (cli + eos = cleos) - command line interface to interact with the blockchain and to manage wallets
    命令行界面接口。用于和区块链交互,管理钱包。

  • keosd (key + eos = keosd) - component that securely stores EOSIO keys in wallets.
    用于在钱包里面安全的存储EOSIO私钥。
Basic EOSIO System Architecture

In the sections that follow, you will build the EOSIO components, and deploy them in a single host, single node test network (testnet) configuration.
正如上图所示,你可以组建你的EOSIO部件,并且部署他们到一个服务器上。

Docker启动EOSIO

前提

安装好了Docker

获取Docker Image

docker pull eosio/eos-dev

启动EOSIO

sudo docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev  /bin/bash -c "nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console"

确认启动

sudo docker logs --tail 10 eosio

~$ sudo docker logs --tail 10 eosio
2018-07-22T13:09:54.000 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e42685a257e... #7746 @ 2018-07-22T13:09:54.000 signed by eosio [trxs: 0, lib: 7745, confirmed: 0]
2018-07-22T13:09:54.500 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e437d138bd4... #7747 @ 2018-07-22T13:09:54.500 signed by eosio [trxs: 0, lib: 7746, confirmed: 0]
2018-07-22T13:09:55.000 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e4465093b1e... #7748 @ 2018-07-22T13:09:55.000 signed by eosio [trxs: 0, lib: 7747, confirmed: 0]
2018-07-22T13:09:55.500 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e4569ee66e8... #7749 @ 2018-07-22T13:09:55.500 signed by eosio [trxs: 0, lib: 7748, confirmed: 0]
2018-07-22T13:09:56.000 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e46329f0e96... #7750 @ 2018-07-22T13:09:56.000 signed by eosio [trxs: 0, lib: 7749, confirmed: 0]
2018-07-22T13:09:56.500 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e47a866965c... #7751 @ 2018-07-22T13:09:56.500 signed by eosio [trxs: 0, lib: 7750, confirmed: 0]
2018-07-22T13:09:57.000 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e48fc250493... #7752 @ 2018-07-22T13:09:57.000 signed by eosio [trxs: 0, lib: 7751, confirmed: 0]
2018-07-22T13:09:57.500 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e49025c04ff... #7753 @ 2018-07-22T13:09:57.500 signed by eosio [trxs: 0, lib: 7752, confirmed: 0]
2018-07-22T13:09:58.000 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e4aee5e20e1... #7754 @ 2018-07-22T13:09:58.000 signed by eosio [trxs: 0, lib: 7753, confirmed: 0]
2018-07-22T13:09:58.501 thread-0   producer_plugin.cpp:1194      produce_block        ] Produced block 00001e4bf4cdcb8e... #7755 @ 2018-07-22T13:09:58.500 signed by eosio [trxs: 0, lib: 7754, confirmed: 0]

生成Cleos命令

alias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888'

生成了cloeos之后,我们可以查询其使用方法

cleos --help

Command Line Interface to EOSIO Client
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit
  -u,--url TEXT=http://localhost:8888/
                              the http/https URL where nodeos is running
  --wallet-url TEXT=http://localhost:8900/
                              the http/https URL where keosd is running
  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers
  -n,--no-verify              don't verify peer certificate when using HTTPS
  -v,--verbose                output verbose actions on error

Subcommands:
  version                     Retrieve version information
  create                      Create various items, on and off the blockchain
  get                         Retrieve various items and information from the blockchain
  set                         Set or update blockchain state
  transfer                    Transfer EOS from account to account
  net                         Interact with local p2p network connections
  wallet                      Interact with local wallet
  sign                        Sign a transaction
  push                        Push arbitrary transactions to the blockchain
  multisig                    Multisig contract commands
  system                      Send eosio.system contract action to the blockchain.

确认我们生成的EOSIO信息

  • ~$ cleos get info
{
  "server_version": "75635168",
  "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
  "head_block_num": 8172,
  "last_irreversible_block_num": 8171,
  "last_irreversible_block_id": "00001feb0ecd88090fed642364f82a201ebfe049354f7bc2f39e8e2ee0c8b2db",
  "head_block_id": "00001fec0632e6d29b03e32d6583a4257e691f7bd1b231b2f3d8a09dc97679e4",
  "head_block_time": "2018-07-22T13:13:27.000",
  "head_block_producer": "eosio",
  "virtual_block_cpu_limit": 200000000,
  "virtual_block_net_limit": 1048576000,
  "block_cpu_limit": 199900,
  "block_net_limit": 1048576
}

关闭我们启动的Docker container

docker stop eosio

图片来源

部分图片来自官方网站

相关链接

HiBlock区块链技术布道 GitHub

DApp

Play with Docker Classroom online

相关文章

网友评论

    本文标题:如何使用Docker快速启动EOSIO环境

    本文链接:https://www.haomeiwen.com/subject/fpwlmftx.html