上一篇文章有详细步骤:EOS本地测试节点搭建---Docker 安装
或者根据 官方文档:
docker: Get Docker CE for Ubuntu
docker-compose: Install Docker Compose
EOSIO Dev Docker镜像是为本地开发而设计的EOSIO软件的编译版本。
从存储库中提取图像:(下载过程比较慢)
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
你的输出应该类似于这个:
1929001ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366974ce4e2a... #13929 @ 2018-05-23T16:32:09.000 signed by eosio [trxs: 0, lib: 13928, confirmed: 0]
1929502ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366aea085023... #13930 @ 2018-05-23T16:32:09.500 signed by eosio [trxs: 0, lib: 13929, confirmed: 0]
1930002ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366b7f074fdd... #13931 @ 2018-05-23T16:32:10.000 signed by eosio [trxs: 0, lib: 13930, confirmed: 0]
1930501ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366cd8222adb... #13932 @ 2018-05-23T16:32:10.500 signed by eosio [trxs: 0, lib: 13931, confirmed: 0]
1931002ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366d5c1ec38d... #13933 @ 2018-05-23T16:32:11.000 signed by eosio [trxs: 0, lib: 13932, confirmed: 0]
1931501ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366e45c1f235... #13934 @ 2018-05-23T16:32:11.500 signed by eosio [trxs: 0, lib: 13933, confirmed: 0]
1932001ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366f98adb324... #13935 @ 2018-05-23T16:32:12.000 signed by eosio [trxs: 0, lib: 13934, confirmed: 0]
1932501ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 00003670a0f01daa... #13936 @ 2018-05-23T16:32:12.500 signed by eosio [trxs: 0, lib: 13935, confirmed: 0]
1933001ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 00003671e8b36e1e... #13937 @ 2018-05-23T16:32:13.000 signed by eosio [trxs: 0, lib: 13936, confirmed: 0]
1933501ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000367257fe1623... #13938 @ 2018-05-23T16:32:13.500 signed by eosio [trxs: 0, lib: 13937, confirmed: 0]
恭喜!您在Docker容器中运行了一个非常简单的单节点区块链!
还要在浏览器中查看该地址以检查RPC接口是否正常工作: http://localhost:8888/v1/chain/get_info
您应该看到类似于以下内容的消息:
{
"server_version": "0961a560",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num": 13780,
"last_irreversible_block_num": 13779,
"last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",
"head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",
"head_block_time": "2018-05-23T16:30:54",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 100000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 99900,
"block_net_limit": 1048576
}
其中 server_version 表示当前服务器运行的 eos 代码版本,其取值为代码的最近一条 commit log 前 8 个字符。对应的正是 build docker image 的时候 master 代码的最新 commit。
head_block_num 表示最新的区块编号,可以理解为区块高度。
last_irreversible_block_num 表示不可逆区块的最大编号,关于这两个的具体区别,可以参见 EOS 技术白皮书中文版
head_block_time 是最新区块的生成时间。
head_block_producer 则表示由哪个节点产生。由于我们只有一个节点,因此其取值一直是 eosio。
关闭节点
docker stop eosio