EOS编译曾花了我几个小时,这里使用Docker Hub的镜像启动的方式, 目前使用最新版本1.0.5
目前官网版本更新太快,很多地方搜索出来的信息都已过时,多看下错误信息自己解决
环境准备
Ubuntu 16.04,官网要求Dock版本:
- Docker Docker 17.05 or higher is required
- docker-compose version >= 1.10.0
实际上docker-compose 1.8也是可以运行的,下面是实际运行版本:
eos@mybc:~$ docker -v
Docker version 18.03.1-ce, build 9ee9f40
eos@mybc:~$ docker-compose -v
docker-compose version 1.8.0, build unknown
docker配置文件
准备docker-compose.yml, 如果你的docker-compose版本>=1.10.0,可以使用推荐的version 3的模式(eos/Docker/docker-compose-eosio1.0.yaml)
version: "2"
services:
nodeosd:
container_name: nodeosd
image: eosio/eos:latest
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
hostname: nodeosd
ports:
- 8888:8888
- 9876:9876
expose:
- "8888"
volumes:
- /opt/eosio/data:/opt/eosio/bin/data-dir
keosd:
container_name: keosd
image: eosio/eos:latest
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
hostname: keosd
links:
- nodeosd
volumes:
- /opt/eosio/data:/opt/eosio/bin/data-dir
启动
拉取最新的镜像(速度慢的去搜索镜像加速)和启动
eos@mybc:~$ docker pull eosio/eos:latest
eos@mybc:~$ docker-compose up -d
查看eos启动日志参考docker logs
启动之后可以查看当前信息(这里经过了格式化):
eos@mybc:~$ curl http://127.0.0.1:8888/v1/chain/get_info
{
"server_version":"c9b7a247",
"chain_id":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num":2229,
"last_irreversible_block_num":2228,
"last_irreversible_block_id":"000008b44680a25353aa1d3d70ade57900b7ece713439449d19977d8611bc743",
"head_block_id":"000008b596592d52d604dbf27961ad7fc125e4f26d0c70ad44c34bbfb3e55c59",
"head_block_time":"2018-06-19T07:05:14.000",
"head_block_producer":"eosio",
"virtual_block_cpu_limit":1854163,
"virtual_block_net_limit":9738884,
"block_cpu_limit":199900,
"block_net_limit":1048576
}
eos@mybc:~$
这表明EOS启动成功,可以查看下/opt/eosio/data目录,配置文件/区块数据/状态数据都在这个目录下。如果创建了钱包,钱包文件也会在这个目录下。
eos@JD:/opt/eosio/data$ ls
blocks config.ini contracts state
eos@JD:/opt/eosio/data$
==contracts目录是编译好的智能合约脚本,后面发行Token需要用到==
配置EOS的CLI
需要永久保存命令的自己直接把alias配置到profile里去
eos@mybc:~$ alias cleos='docker-compose exec keosd /opt/eosio/bin/cleos -u http://nodeosd:8888 --wallet-url http://localhost:8900'
eos@mybc:~$ cleos get info
{
"server_version": "c9b7a247",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num": 2749,
"last_irreversible_block_num": 2748,
"last_irreversible_block_id": "00000abc4f89b6d0ae2e14be112478aa16e5aeffa1fdf5a03a3afa72060a7e3f",
"head_block_id": "00000abdc8aa697eabd2f042bfe4cd3803121a9ce65b64537ae1d573bb0296af",
"head_block_time": "2018-06-19T07:09:34.000",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 3119214,
"virtual_block_net_limit": 16384995,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}
eos@mybc:~$