多节点Docker Compose部署
本地集群
部署一个4个node的Tendermint区块链网路。
获取Tendermint源码
可以使用git活go get,这里略。
编译
$ make build-linux
$ make build-docker-localnode
启动
$ make localnet-start
docker-compose down
Removing network tendermint_localnet
WARNING: Network tendermint_localnet not found.
make[1]: Entering directory '/home/frank/project/go/tendermint/src/github.com/tendermint/tendermint/networks/local'
docker build --tag tendermint/localnode localnode
Sending build context to Docker daemon 4.608kB
Step 1/11 : FROM alpine:3.7
---> 6d1ef012b567
Step 2/11 : MAINTAINER Greg Szabo <greg@tendermint.com>
---> Using cache
---> 56dc57e31027
Step 3/11 : RUN apk update && apk upgrade && apk --no-cache add curl jq file
---> Using cache
---> e76f72fbd3bd
Step 4/11 : VOLUME [ /tendermint ]
---> Using cache
---> 2db2bc1737b1
Step 5/11 : WORKDIR /tendermint
---> Using cache
---> 68e161d1c688
Step 6/11 : EXPOSE 26656 26657
---> Using cache
---> 82f1bd12e713
Step 7/11 : ENTRYPOINT ["/usr/bin/wrapper.sh"]
---> Using cache
---> 9cea399ec367
Step 8/11 : CMD ["node", "--proxy_app", "kvstore"]
---> Using cache
---> 36510b247587
Step 9/11 : STOPSIGNAL SIGTERM
---> Using cache
---> 77d014c73f91
Step 10/11 : COPY wrapper.sh /usr/bin/wrapper.sh
---> Using cache
---> 12f76b156566
Step 11/11 : COPY config-template.toml /etc/tendermint/config-template.toml
---> Using cache
---> 5bd6dc502548
Successfully built 5bd6dc502548
Successfully tagged tendermint/localnode:latest
make[1]: Leaving directory '/home/frank/project/go/tendermint/src/github.com/tendermint/tendermint/networks/local'
docker-compose up
Creating network "tendermint_localnet" with driver "bridge"
Creating node2 ... done
Creating node0 ... done
Creating node1 ... done
Creating node3 ... done
Attaching to node2, node0, node3, node1
node0 | I[2020-02-25|12:13:01.616] Version info module=main software=0.33.1 block=10 p2p=7
node2 | I[2020-02-25|12:13:00.739] Version info module=main software=0.33.1 block=10 p2p=7
容器
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
09946ef320dd tendermint/localnode "/usr/bin/wrapper.sh…" 2 minutes ago Exited (137) About a minute ago node1
1b1b752e86e1 tendermint/localnode "/usr/bin/wrapper.sh…" 2 minutes ago Exited (137) About a minute ago node3
2661a76dcd5e tendermint/localnode "/usr/bin/wrapper.sh…" 2 minutes ago Exited (137) About a minute ago node0
77e667017254 tendermint/localnode "/usr/bin/wrapper.sh…" 2 minutes ago Exited (137) About a minute ago node2
镜像
$ sudo docker images | grep tendermint
tendermint/localnode latest 5bd6dc502548 4 weeks ago 13.7MB
tendermint/tendermint latest d0f9c639fc2d 5 weeks ago 39.6MB
停止
$ make localnet-stop
docker-compose down
Removing node1 ... done
Removing node3 ... done
Removing node0 ... done
Removing node2 ... done
Removing network tendermint_localnet