关掉所有停止或者在运行的容器:
docker rm -f $(docker ps -aq) docker rmi -f $(docker images | grep fabcar | awk ‘{print $3}‘)
启动网络:
1、清理环境
./byfn.sh down
2、生成默认的BYFN构件:
./byfn.sh generate
3、启动网络并执行CLI容器内脚本
./byfn.sh up
下载镜像:
cd fabric-samples/scripts ./bootstrap.sh -b
启动节点:
docker-compose -f docker-compose-peer0-org3.yaml up -d
进入容器内部: cli ,容器名称
docker exec -it cli bash
把文件从容器中取出来,例如:mychannel.block .
docker container cp cli:/opt/gopath/src/github.com/hyperledger/fabric/peer/mychannel.block .
复制到容器中:
docker cp ./mychannel.block cli:/opt/gopath/src/github.com/hyperledger/fabric/peer/
查看日志
docker logs -f orderer.example.com docker logs ${id}
报错: iptables: No chain/target/match by that name
方法:
service docker restart
或
systemctl restart docker
--installed标志列出在当前peer节点上安装的链码:
peer chaincode list --installed
安装链码:
peer chaincode install -n mycar -v 1.0 -p github.com/chaincode/fabcar/go
初始化:
peer chaincode instantiate -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc -l golang -v 1.0 -c ‘{"Args":["init","a","100","b","200"]}‘ -P ‘AND (‘\‘‘Org1MSP.peer‘\‘‘,‘\‘‘Org2MSP.peer‘\‘‘)‘
查询:
peer chaincode query -C mychannel -n mycc -c ‘{"Args":["query","a"]}‘
转账:
peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c ‘{"Args":["invoke","a","b","10"]}‘