# docker tag IMAGEID(镜像id) REPOSITORY:TAG(仓库:标签)docker tag 625237d887db hyperledger/fabric-tools:latest
docker tag ee643d889779 hyperledger/fabric-peer:latest
docker tag df64446ac2df hyperledger/fabric-orderer:latest
docker tag da4f00cb576a hyperledger/fabric-ccenv:latest
docker tag 0287ebf8aaf3 hyperledger/fabric-baseos:latest
docker tag 4ea287b75c63 hyperledger/fabric-ca:latest
最终的镜像为:
运行测试
启动fabric网络
进入fabric-sample的test-network目录
1
cd fabric-samples/test-network
运行./network.sh up 启动网络
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Creating network "fabric_test" with the default driver
Creating volume "docker_orderer.example.com" with default driver
Creating volume "docker_peer0.org1.example.com" with default driver
Creating volume "docker_peer0.org2.example.com" with default driver
Creating peer0.org1.example.com ... doneCreating orderer.example.com ... doneCreating peer0.org2.example.com ... doneCreating cli ... doneCONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS
NAMES
7738c1e84751 hyperledger/fabric-tools:latest "/bin/bash" Less than a second ago Up Less than a second cli
1f24de2c6cd5 hyperledger/fabric-peer:latest "peer node start"2 seconds ago Up Less than a second 0.0.0.0:9051->9051/tcp, :::9051->9051/tcp, 0.0.0.0:19051->19051/tcp, :::19051->19051/tcp peer0.org2.example.com
bfc48b20360c hyperledger/fabric-orderer:latest "orderer"2 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp, :::7050->7050/tcp, 0.0.0.0:7053->7053/tcp, :::7053->7053/tcp, 0.0.0.0:17050->17050/tcp, :::17050->17050/tcp orderer.example.com
b9a61fdaf47a hyperledger/fabric-peer:latest "peer node start"2 seconds ago Up Less than a second 0.0.0.0:7051->7051/tcp, :::7051->7051/tcp, 0.0.0.0:17051->17051/tcp, :::17051->17051/tcp peer0.org1.example.com
./network.sh deployCC -c testchannel -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
此命令执行后可能会出现错误:scripts/deployCC.sh: line 114: log.txt: Permission denied,很明显这是权限不足所致,加上sudo试试:
1
./network.sh deployCC -c testchannel -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go
加上sudo后出现新的错误:deployCC.sh: line 59: go: command not found。检查本用户 go 命令可用,检查 root 用户 go 命令可用,单单 sudo 后不能用。查阅资料后发现这是因为 linux 系统为了安全,限制在使用 sudo 时会清空自定义的环境变量,最简单的解决方法是在/etc/sudoers文件中直接将该限制注释1:
加上注释后重新执行上条命令,又出现了新的错误:
1
go: github.com/golang/[email protected]: Get "https://proxy.golang.org/github.com/golang/protobuf/@v/v1.3.2.mod": dial tcp 172.217.160.81:443: i/o timeout
很明显这是因为本地网络无法访问proxy.golang.org所致,在命令行输入go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct命令配置国内代理2后再次执行。令人意外的是错误不变,设置的代理没有生效?手动使用go get github.com/golang/protobuf手动下载安装后再次运行错误还是不变,此时检查本地GOPATH目录下已有github.com/golang/protobuf包,为什么没有识别到?此时灵机一动,使用go env查看 GOPATH 环境变量,发现与本地用户不一致,原来 sudo 命令会使用 root 的 go 环境变量,而之前设置的代理、下载的包都只能在本地用户下生效,因此这个问题最终的解决方案是直接切换到 root 用户下重新配置 go 代理并运行。成功运行后可看见如下结果: