我在Windows 7 64位操作系统上使用docker-Toolbox设置了hyperledger fabric 0.6 env,我使用REST API客户端来触发请求。以下是我的4-peer-ca.yaml docker撰写文件: -
version: "2"
services: baseimage: image: hyperledger/fabric-baseimage:latest
membersrvc:
image: hyperledger/fabric-membersrvc
ports:
- "7054:7054"
command: membersrvc
environment:
- MEMBERSRVC_CA_LOGGING_SERVER=INFO
- MEMBERSRVC_CA_LOGGING_CA=INFO
- MEMBERSRVC_CA_LOGGING_ECA=INFO
- MEMBERSRVC_CA_LOGGING_ECAP=INFO
- MEMBERSRVC_CA_LOGGING_ECAA=INFO
- MEMBERSRVC_CA_LOGGING_ACA=INFO
- MEMBERSRVC_CA_LOGGING_ACAP=INFO
- MEMBERSRVC_CA_LOGGING_TCA=INFO
- MEMBERSRVC_CA_LOGGING_TCAP=INFO
- MEMBERSRVC_CA_LOGGING_TCAA=INFO
- MEMBERSRVC_CA_LOGGING_TLSCA=INFO
vp0:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
command: sh -c "sleep 10; peer node start"
links: - membersrvc
vp1:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "8050:7050"
- "8051:7051"
- "8053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp1
- CORE_SECURITY_ENROLLID=test_vp1
- CORE_SECURITY_ENROLLSECRET=5wgHK9qqYaPy
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links: - membersrvc - vp0
command: sh -c "sleep 10; peer node start"
vp2:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "9050:7050"
- "9051:7051"
- "9053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp2
- CORE_SECURITY_ENROLLID=test_vp2
- CORE_SECURITY_ENROLLSECRET=vQelbRvja7cJ
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links: - membersrvc - vp0
command: sh -c "sleep 10; peer node start"
vp3:
image: hyperledger/fabric-peer
volumes: - /var/run/docker.sock:/var/run/docker.sock
ports:
- "10050:7050"
- "10051:7051"
- "10053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp3
- CORE_SECURITY_ENROLLID=test_vp3
- CORE_SECURITY_ENROLLSECRET=9LKqKH5peurL
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links: - membersrvc - vp0
command: sh -c "sleep 10; peer node start"**
// ------------ 使用docker-compose up命令,我的服务器启动,所有4个对等体都成功创建。 在另一个docker终端我执行了以下命令,它也正常工作:
CORE_CHAINCODE_ID_NAME=mycc006 CORE_PEER_ADDRESS=192.168.99.100:7051 ./chaincode_example02
由于我使用的是docker toolbox,因此只有192.168.99.100是CORE_PEER_ADDRESS的可接受IP地址。
REST API请求仅对所有操作的响应 - 192.168.99.100:7050/chaincode
您可以在上面的docker-compose文件中看到我已将vp1,vp2,vp3映射到不同的端口并转发到vp0。
但是当我尝试使用任何其他对等体时,例如vp1使用192.168.99.100:8050/chaincode,请求失败,因为vp1,vp2,vp3没有响应,即使我已经与这些对等体专门映射了端口。 Docker ps命令显示memersrvc和所有4个对等容器正在运行,但端口仅分配给vp0。
如何将其他对等体vp1,vp2,vp3与端口映射,以便通过REST API访问它们?任何帮助或指导将不胜感激。
感谢。
答案 0 :(得分:2)
你的docker-compose文件看起来不错,除了映射中的一些小问题,我猜这与stackoverflow上的渲染有关。 问题是,REST端点根本不起作用吗?例如 http://localhost:10050/chain 无法访问?如果是这样,您可能需要确保使用正确的图像 hyperledger / fabric-peer:x86_64-0.6.1-preview 因为docker-compose文件也适用于1.0-alpha图像,但是缺少REST API。 稍微修改了我附加的docker-compose文件,开箱即用。如果这样可以解决您的问题,您必须查看泊坞窗图像并查看最新标记指向的位置。
version: "2"
services: # baseimage: image: hyperledger/fabric-baseimage:latest
membersrvc:
image: hyperledger/fabric-membersrvc
ports:
- "7054:7054"
command: membersrvc
environment:
- MEMBERSRVC_CA_LOGGING_SERVER=INFO
- MEMBERSRVC_CA_LOGGING_CA=INFO
- MEMBERSRVC_CA_LOGGING_ECA=INFO
- MEMBERSRVC_CA_LOGGING_ECAP=INFO
- MEMBERSRVC_CA_LOGGING_ECAA=INFO
- MEMBERSRVC_CA_LOGGING_ACA=INFO
- MEMBERSRVC_CA_LOGGING_ACAP=INFO
- MEMBERSRVC_CA_LOGGING_TCA=INFO
- MEMBERSRVC_CA_LOGGING_TCAP=INFO
- MEMBERSRVC_CA_LOGGING_TCAA=INFO
- MEMBERSRVC_CA_LOGGING_TLSCA=INFO
vp0:
image: hyperledger/fabric-peer:x86_64-0.6.1-preview
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "7050:7050"
- "7051:7051"
- "7053:7053"
environment:
- CORE_PEER_ID=vp0
- CORE_SECURITY_ENROLLID=test_vp0
- CORE_SECURITY_ENROLLSECRET=MwYpmSRjupbT
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
command: sh -c "sleep 10; peer node start"
links:
- membersrvc
vp1:
image: hyperledger/fabric-peer:x86_64-0.6.1-preview
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "8050:7050"
- "8051:7051"
- "8053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp1
- CORE_SECURITY_ENROLLID=test_vp1
- CORE_SECURITY_ENROLLSECRET=5wgHK9qqYaPy
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links:
- membersrvc
- vp0
command: sh -c "sleep 10; peer node start"
vp2:
image: hyperledger/fabric-peer:x86_64-0.6.1-preview
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "9050:7050"
- "9051:7051"
- "9053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp2
- CORE_SECURITY_ENROLLID=test_vp2
- CORE_SECURITY_ENROLLSECRET=vQelbRvja7cJ
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links:
- membersrvc
- vp0
command: sh -c "sleep 10; peer node start"
vp3:
image: hyperledger/fabric-peer:x86_64-0.6.1-preview
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "10050:7050"
- "10051:7051"
- "10053:7053"
environment:
- CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051
- CORE_PEER_ID=vp3
- CORE_SECURITY_ENROLLID=test_vp3
- CORE_SECURITY_ENROLLSECRET=9LKqKH5peurL
- CORE_PEER_DISCOVERY_PERIOD=60s
- CORE_PEER_DISCOVERY_TOUCHPERIOD=61s
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_VM_ENDPOINT=unix:///var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_PKI_ECA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TCA_PADDR=membersrvc:7054
- CORE_PEER_PKI_TLSCA_PADDR=membersrvc:7054
- CORE_SECURITY_ENABLED=true
- CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft
- CORE_PBFT_GENERAL_MODE=batch
- CORE_PBFT_GENERAL_N=4
links:
- membersrvc
- vp0
command: sh -c "sleep 10; peer node start"