我正在尝试使用docker测试fabric chaincode example02。我是新手:)
这是我的docker-compose.yml
:
membersrvc:
image: hyperledger/fabric-membersrvc
command: membersrvc
vp0:
image: hyperledger/fabric-peer
environment:
- CORE_PER_ID=vp0
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://0.0.0.0:2375
- CORE_LOGGING_LEVEL=DEBUG
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
vp1:
extends:
service: vp0
environment:
- CORE_PEER_ID=vp1
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
vp2:
extends:
service: vp0
environment:
- CORE_PEER_ID=vp2
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
links:
- vp0
我跑(我指的是Fabric chaincode setup page):
1号航站楼:
$ docker-compose up
2号航站楼:
$ cd /hyperledger/examples/chaincode/go/chaincode_example02
$ CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7051 ./chaincode_example02
3号航站楼:
$ peer chaincode deploy -n mycc -c '{"Args": ["init", "a","100", "b", "200"]}'
它在终端1,2中运行良好。但终端3显示连接错误。
2016/10/21 04:39:15 grpc: addrConn.resetTransport failed to create client
transport: connection error: desc = "transport: dial tcp 0.0.0.0:7051:
getsockopt: connection refused"; Reconnecting to {"0.0.0.0:7051" <nil>}
Error: Error building chaincode: Error trying to connect to local peer:
grpc: timed out when dialing
有什么问题?
答案 0 :(得分:3)
似乎你缺少compose语句来将所需的端口从docker容器映射到主机(你正在尝试peer命令)。因此,对等进程可能正在侦听对等端口容器内的端口7051,但此连接不可用于终端3中此容器外部使用的对等命令。
您可以使用&#39;端口&#39;来映射端口。标签。例如:
membersrvc:
image: hyperledger/fabric-membersrvc
ports:
- "7054:7054"
command: membersrvc
vp0:
image: hyperledger/fabric-peer
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PER_ID=vp0
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=http://0.0.0.0:2375
- CORE_LOGGING_LEVEL=DEBUG
command: sh -c "sleep 5; peer node start --peer-chaincodedev"
在终端3中执行peer chaincode deploy ...
之前,您可以使用
netstat -lnptu |grep 7051