实验第四节——启动容器
Posted 想学习安全的小白
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验第四节——启动容器相关的知识,希望对你有一定的参考价值。
一、本实验所需容器介绍
- 一个cli端容器,通过调整cli端容器使用的证书,以不同身份来使用cli端容器
- 三个orderere容器——orderer0,orderer1,orderer2
- 四个peer容器——org1的peer0,org1的peer1,org2的peer0,org2的peer1
- 这八个容器运行在一个自定义的容器网络中,创建网络命令:
docker network create fabric_net
二、创建cli容器
- 创建chaincodes目录,用于之后上传chaincode相关文件,命令:
mkdir -p /home/test_fabric/chaincodes
- 以docker run形式创建容器,通过设置环境变量
CORE_PEER_TLS_ENABLED=true
开启tls,命令,
docker run --rm -it --name fabric-cli --hostname fabric-cli --network fabric_net \\
-e CORE_PEER_ID=fabric-cli \\
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt \\
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key \\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e CORE_PEER_TLS_ENABLED=true \\
-e ORDERER_CA=/etc/hyperledger/fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/tlscacerts/tlsca.example.com-cert.pem \\
-v /home/test_fabric/crypto-config.yaml:/etc/hyperledger/fabric/crypto-config.yaml \\
-v /home/test_fabric/crypto-config:/etc/hyperledger/fabric/crypto-config \\
-v /home/test_fabric/channel-artifacts:/tmp/channel-artifacts \\
-v /home/test_fabric/configtx.yaml:/etc/hyperledger/fabric/configtx.yaml \\
-v /home/test_fabric/chaincodes:/go/src/chaincodes \\
yeasy/hyperledger-fabric:2.3.3 /bin/bash
三、创建orderer容器
3.1、创建orderer0容器
- 创建命令
docker run -it --name orderer0.example.com --hostname orderer0.example.com -p 7050:7050 --network fabric_net \\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 \\
-e ORDERER_GENERAL_LISTENPORT=7050 \\
-e ORDERER_GENERAL_GENESISMETHOD=file \\
-e ORDERER_GENERAL_BOOTSTRAPFILE=/etc/hyperledger/fabric/orderer.genesis.block \\
-e ORDERER_GENERAL_LOCALMSPID=OrdererMSP \\
-e ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/fabric/msp \\
-e ORDERER_GENERAL_LEDGERTYPE=file \\
-e ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443 \\
-e ORDERER_METRICS_PROVIDER=prometheus \\
-e ORDERER_GENERAL_TLS_ENABLED=true \\
-e ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/fabric/tls/server.key \\
-e ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/fabric/tls/server.crt \\
-e ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt] \\
-e ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/etc/hyperledger/fabric/tls/server.key \\
-e ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/etc/hyperledger/fabric/tls/server.crt \\
-e ORDERER_GENERAL_CLUSTER_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt] \\
-v /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/tls/:/etc/hyperledger/fabric/tls \\
-v /home/test_fabric/channel-artifacts/orderer0.genesis.block:/etc/hyperledger/fabric/orderer.genesis.block \\
yeasy/hyperledger-fabric-orderer:2.3.3 /bin/bash
- 创建后进入容器执行命令:
orderer start
3.2、创建orderer1容器
- 创建命令
docker run -it --name orderer1.example.com --hostname orderer1.example.com -p 8050:7050 --network fabric_net\\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e ORDERER_GENERAL_CLUSTER_SENDBUFFERSIZE=10 \\
-e ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 \\
-e ORDERER_GENERAL_LISTENPORT=7050 \\
-e ORDERER_GENERAL_GENESISMETHOD=file \\
-e ORDERER_GENERAL_BOOTSTRAPFILE=/etc/hyperledger/fabric/orderer.genesis.block \\
-e ORDERER_GENERAL_LOCALMSPID=OrdererMSP \\
-e ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/fabric/msp \\
-e ORDERER_GENERAL_LEDGERTYPE=file \\
-e ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443 \\
-e ORDERER_METRICS_PROVIDER=prometheus \\
-e ORDERER_GENERAL_TLS_ENABLED=true \\
-e ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/fabric/tls/server.key \\
-e ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/fabric/tls/server.crt \\
-e ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt] \\
-e ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/etc/hyperledger/fabric/tls/server.key \\
-e ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/etc/hyperledger/fabric/tls/server.crt \\
-e ORDERER_GENERAL_CLUSTER_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt] \\
-v /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/tls/:/etc/hyperledger/fabric/tls \\
-v /home/test_fabric/channel-artifacts/orderer1.genesis.block:/etc/hyperledger/fabric/orderer.genesis.block \\
yeasy/hyperledger-fabric-orderer:2.3.3 /bin/bash
- 进入容器后执行命令:
orderer start
3.3、创建orderer2容器
- 创建命令
docker run -it --name orderer2.example.com --hostname orderer2.example.com -p 9050:7050 --network fabric_net\\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e ORDERER_GENERAL_CLUSTER_SENDBUFFERSIZE=10 \\
-e ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 \\
-e ORDERER_GENERAL_LISTENPORT=7050 \\
-e ORDERER_GENERAL_GENESISMETHOD=file \\
-e ORDERER_GENERAL_BOOTSTRAPFILE=/etc/hyperledger/fabric/orderer.genesis.block \\
-e ORDERER_GENERAL_LOCALMSPID=OrdererMSP \\
-e ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/fabric/msp \\
-e ORDERER_GENERAL_LEDGERTYPE=file \\
-e ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443 \\
-e ORDERER_METRICS_PROVIDER=prometheus \\
-e ORDERER_GENERAL_TLS_ENABLED=true \\
-e ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/fabric/tls/server.key \\
-e ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/fabric/tls/server.crt \\
-e ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt] \\
-e ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/etc/hyperledger/fabric/tls/server.key \\
-e ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/etc/hyperledger/fabric/tls/server.crt \\
-e ORDERER_GENERAL_CLUSTER_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt] \\
-v /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/:/etc/hyperledger/fabric/tls \\
-v /home/test_fabric/channel-artifacts/orderer2.genesis.block:/etc/hyperledger/fabric/orderer.genesis.block \\
yeasy/hyperledger-fabric-orderer:2.3.3 /bin/bash
- 进入容器后执行命令:
orderer start
四、创建peer容器
4.1、创建org1-peer0容器
- 命令:
docker run -it --name peer0.org1.example.com --hostname peer0.org1.example.com -p 7051:7051 --network fabric_net \\
-e CORE_PEER_ID=peer0.org1.example.com \\
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 \\
-e CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052 \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 \\
-e CORE_PEER_LOCALMSPID=Org1MSP \\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e CORE_PEER_ADDRESSAUTODETECT=false \\
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net \\
-e CORE_PEER_GOSSIP_USELEADERELECTION=true \\
-e CORE_PEER_GOSSIP_ORGLEADER=false \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 \\
-e CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 \\
-e CORE_METRICS_PROVIDER=prometheus \\
-e CORE_PEER_PROFILE_ENABLED=false \\
-e CORE_PEER_TLS_ENABLED=true \\
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt \\
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key \\
-e CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt \\
-e CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3 \\
-e CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3 \\
-v /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls \\
-v /var/run/docker.sock:/var/run/docker.sock \\
yeasy/hyperledger-fabric-peer:2.3.3 /bin/bash
- 进入容器执行命令:
peer node start
4.2、创建org1-peer1容器
- 创建命令
docker run -it --name peer1.org1.example.com --hostname peer1.org1.example.com -p 8051:7051 --network fabric_net \\
-e CORE_PEER_ID=peer1.org1.example.com \\
-e CORE_PEER_ADDRESS=peer1.org1.example.com:7051 \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051 \\
-e CORE_PEER_CHAINCODELISTENADDRESS=peer1.org1.example.com:7052 \\
-e CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 \\
-e CORE_PEER_LOCALMSPID=Org1MSP \\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e CORE_PEER_ADDRESSAUTODETECT=false \\
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net \\
-e CORE_PEER_GOSSIP_USELEADERELECTION=true \\
-e CORE_PEER_GOSSIP_ORGLEADER=false \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 \\
-e CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 \\
-e CORE_METRICS_PROVIDER=prometheus \\
-e CORE_PEER_PROFILE_ENABLED=false \\
-e CORE_PEER_TLS_ENABLED=true \\
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt \\
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key \\
-e CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt \\
-e CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3 \\
-e CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3 \\
-v /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls \\
-v /var/run/docker.sock:/var/run/docker.sock \\
yeasy/hyperledger-fabric-peer:2.3.3 /bin/bash
- 进入容器执行命令:
peer node start
4.3、创建org2-peer0容器
- 创建命令
docker run -it --name peer0.org2.example.com --hostname peer0.org2.example.com -p 9051:7051 --network fabric_net \\
-e CORE_PEER_ID=peer0.org2.example.com \\
-e CORE_PEER_ADDRESS=peer0.org2.example.com:7051 \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051 \\
-e CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052 \\
-e CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051 \\
-e CORE_PEER_LOCALMSPID=Org2MSP \\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e CORE_PEER_ADDRESSAUTODETECT=false \\
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net \\
-e CORE_PEER_GOSSIP_USELEADERELECTION=true \\
-e CORE_PEER_GOSSIP_ORGLEADER=false \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 \\
-e CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 \\
-e CORE_METRICS_PROVIDER=prometheus \\
-e CORE_PEER_PROFILE_ENABLED=false \\
-e CORE_PEER_TLS_ENABLED=true \\
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt \\
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key \\
-e CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt \\
-e CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3 \\
-e CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3 \\
-v /home/test_fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls \\
-v /var/run/docker.sock:/var/run/docker.sock \\
yeasy/hyperledger-fabric-peer:2.3.3 /bin/bash
- 进入容器执行命令:
peer node start
4.4、创建org2-peer0容器
- 创建命令
docker run -it --name peer1.org2.example.com --hostname peer1.org2.example.com -p 10051:7051 --network fabric_net \\
-e CORE_PEER_ID=peer1.org2.example.com \\
-e CORE_PEER_ADDRESS=peer1.org2.example.com:7051 \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051 \\
-e CORE_PEER_CHAINCODELISTENADDRESS=peer1.org2.example.com:7052 \\
-e CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051 \\
-e CORE_PEER_LOCALMSPID=Org2MS \\
-e FABRIC_LOGGING_SPEC=DEBUG \\
-e CORE_PEER_ADDRESSAUTODETECT=false \\
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net \\
-e CORE_PEER_GOSSIP_USELEADERELECTION=true \\
-e CORE_PEER_GOSSIP_ORGLEADER=false \\
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 \\
-e CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 \\
-e CORE_METRICS_PROVIDER=prometheus \\
-e CORE_PEER_PROFILE_ENABLED=false \\
-e CORE_PEER_TLS_ENABLED=true \\
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt \\
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key \\
-e CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt \\
-e CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3 \\
-e CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3 \\
-v /home/test_fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp \\
-v /home/test_fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls \\
-v /var/run/docker.sock:/var/run/docker.sock \\
yeasy/hyperledger-fabric-peer:2.3.3 /bin/bash
- 进入容器执行命令:
peer node start
五、通过docker-compose.yaml文件启动orderer以及peer节点
- 因为cli容器没有阻塞语句,所以不建议使用此方法创建cli容器
- 先拉取相关镜像,命令
docker pull yeasy/hyperledger-fabric-orderer:2.3.3
docker pull yeasy/hyperledger-fabric-peer:2.3.3
- 创建docker-compose.yaml文件,命令:
touch /home/test_fabric/docker-compose.yaml
- 使用docker-compose.yaml启动,命令:
docker-compose -f /home/test_fabric/docker-compose.yaml up -d
- docker-compose.yaml内容
version: '3'
services:
orderer0.example.com: # There can be multiple orderers
container_name: orderer0.example.com
hostname: orderer0.example.com
image: yeasy/hyperledger-fabric-orderer:2.3.3
network_mode: fabric_net
ports:
- 7050:7050
environment:
- FABRIC_LOGGING_SPEC=DEBUG
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 # default: 127.0.0.1
- ORDERER_GENERAL_LISTENPORT=7050
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_BOOTSTRAPFILE=/etc/hyperledger/fabric/orderer.genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/fabric/msp
- ORDERER_GENERAL_LEDGERTYPE=file
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443
- ORDERER_METRICS_PROVIDER=prometheus
- ORDERER_GENERAL_TLS_ENABLED=true
- ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/fabric/tls/server.key
- ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/fabric/tls/server.crt
- ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt]
- ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/etc/hyperledger/fabric/tls/server.key
- ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/etc/hyperledger/fabric/tls/server.crt
- ORDERER_GENERAL_CLUSTER_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt]
volumes:
- /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp:/etc/hyperledger/fabric/msp
- /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/tls/:/etc/hyperledger/fabric/tls
- /home/test_fabric/channel-artifacts/orderer0.genesis.block:/etc/hyperledger/fabric/orderer.genesis.block
command: orderer start
orderer1.example.com: # There can be multiple orderers
container_name: orderer1.example.com
hostname: orderer1.example.com
image: yeasy/hyperledger-fabric-orderer:2.3.3
network_mode: fabric_net
ports:
- 8050:7050
environment:
- ORDERER_GENERAL_CLUSTER_SENDBUFFERSIZE=10
- FABRIC_LOGGING_SPEC=DEBUG
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 # default: 127.0.0.1
- ORDERER_GENERAL_LISTENPORT=7050
- ORDERER_GENERAL_GENESISMETHOD=file # default: provisional
- ORDERER_GENERAL_BOOTSTRAPFILE=/etc/hyperledger/fabric/orderer.genesis.block # by default, all materials should be put under $FABRIC_CFG_PATH, which defaults to /etc/hyperledger/fabric
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP # default: DEFAULT
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/fabric/msp
- ORDERER_GENERAL_LEDGERTYPE=file
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443 # operation RESTful API
- ORDERER_METRICS_PROVIDER=prometheus # prometheus will pull metrics from orderer via /metrics RESTful API
- ORDERER_GENERAL_TLS_ENABLED=true # default: false
- ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/fabric/tls/server.key
- ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/fabric/tls/server.crt
- ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt]
- ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/etc/hyperledger/fabric/tls/server.key
- ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/etc/hyperledger/fabric/tls/server.crt
- ORDERER_GENERAL_CLUSTER_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt]
volumes:
- /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp:/etc/hyperledger/fabric/msp
- /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/tls/:/etc/hyperledger/fabric/tls
- /home/test_fabric/channel-artifacts/orderer1.genesis.block:/etc/hyperledger/fabric/orderer.genesis.block
command: orderer start
orderer2.example.com: # There can be multiple orderers
container_name: orderer2.example.com
hostname: orderer2.example.com
image: yeasy/hyperledger-fabric-orderer:2.3.3
network_mode: fabric_net
ports:
- 9050:7050
environment:
- ORDERER_GENERAL_CLUSTER_SENDBUFFERSIZE=10
- FABRIC_LOGGING_SPEC=DEBUG
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 # default: 127.0.0.1
- ORDERER_GENERAL_LISTENPORT=7050
- ORDERER_GENERAL_GENESISMETHOD=file # default: provisional
- ORDERER_GENERAL_BOOTSTRAPFILE=/etc/hyperledger/fabric/orderer.genesis.block # by default, all materials should be put under $FABRIC_CFG_PATH, which defaults to /etc/hyperledger/fabric
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP # default: DEFAULT
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/fabric/msp
- ORDERER_GENERAL_LEDGERTYPE=file
- ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:8443 # operation RESTful API
- ORDERER_METRICS_PROVIDER=prometheus # prometheus will pull metrics from orderer via /metrics RESTful API
- ORDERER_GENERAL_TLS_ENABLED=true # default: false
- ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/fabric/tls/server.key
- ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/fabric/tls/server.crt
- ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt]
- ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/etc/hyperledger/fabric/tls/server.key
- ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/etc/hyperledger/fabric/tls/server.crt
- ORDERER_GENERAL_CLUSTER_ROOTCAS=[/etc/hyperledger/fabric/tls/ca.crt]
volumes:
- /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp:/etc/hyperledger/fabric/msp
- /home/test_fabric/crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/tls/:/etc/hyperledger/fabric/tls
- /home/test_fabric/channel-artifacts/orderer2.genesis.block:/etc/hyperledger/fabric/orderer.genesis.block
command: orderer start
peer0.org1.example.com:
container_name: peer0.org1.example.com
hostname: peer0.org1.example.com
image: yeasy/hyperledger-fabric-peer:2.3.3
network_mode: fabric_net
ports:
- 7051:7051
environment:
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org1.example.com:7052
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- FABRIC_LOGGING_SPEC=DEBUG
- CORE_PEER_ADDRESSAUTODETECT=false
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net # uncomment this to use specific network
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false # whether this node is the org leader, default to false
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 # change to external addr for peers in other orgs
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 # operation RESTful API
- CORE_METRICS_PROVIDER=prometheus # prometheus will pull metrics from fabric via /metrics RESTful API
- CORE_PEER_PROFILE_ENABLED=false
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
- CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3
- CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3
volumes:
- /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
- /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
- /var/run/docker.sock:/var/run/docker.sock
command: peer node start
depends_on:
- orderer0.example.com
- orderer1.example.com
- orderer2.example.com
peer1.org1.example.com:
container_name: peer1.org1.example.com
hostname: peer1.org1.example.com
image: yeasy/hyperledger-fabric-peer:2.3.3
network_mode: fabric_net
ports:
- 8051:7051
environment:
- CORE_PEER_ID=peer1.org1.example.com
- CORE_PEER_ADDRESS=peer1.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051
- CORE_PEER_CHAINCODELISTENADDRESS=peer1.org1.example.com:7052
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- FABRIC_LOGGING_SPEC=DEBUG
- CORE_PEER_ADDRESSAUTODETECT=false
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net # uncomment this to use specific network
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false # whether this node is the org leader, default to false
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 # change to external addr for peers in other orgs
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 # operation RESTful API
- CORE_METRICS_PROVIDER=prometheus # prometheus will pull metrics from fabric via /metrics RESTful API
- CORE_PEER_PROFILE_ENABLED=false
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
- CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3
- CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3
volumes:
- /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
- /home/test_fabric/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
- /var/run/docker.sock:/var/run/docker.sock
command: peer node start
depends_on:
- orderer0.example.com
- orderer1.example.com
- orderer2.example.com
peer0.org2.example.com:
container_name: peer0.org2.example.com
hostname: peer0.org2.example.com
image: yeasy/hyperledger-fabric-peer:2.3.3
network_mode: fabric_net
ports:
- 9051:7051
environment:
- CORE_PEER_ID=peer0.org2.example.com
- CORE_PEER_ADDRESS=peer0.org2.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
- CORE_PEER_CHAINCODELISTENADDRESS=peer0.org2.example.com:7052
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
- CORE_PEER_LOCALMSPID=Org2MSP
- FABRIC_LOGGING_SPEC=DEBUG
- CORE_PEER_ADDRESSAUTODETECT=false
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_net # uncomment this to use specific network
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false # whether this node is the org leader, default to false
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=0.0.0.0:7051 # change to external addr for peers in other orgs
- CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9443 # operation RESTful API
- CORE_METRICS_PROVIDER=prometheus # prometheus will pull metrics from fabric via /metrics RESTful API
- CORE_PEER_PROFILE_ENABLED=false
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
- CORE_CHAINCODE_BUILDER=hyperledger/fabric-ccenv:2.3.3
- CORE_CHAINCODE_NODE_RUNTIME=hyperledger/fabric-nodeenv:2.3.3
volumes:
- /home/test_fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
- /home/test_fabric/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
- /var/run/docker.sock:/var/run/docker.sock
command: peer node start
depends_on:
- orderer0.example.com
- orderer1.example.com
- orderer2.example.com
peer1.org2.example.com:
container_name: peer1.org2.example.com
hostname:以上是关于实验第四节——启动容器的主要内容,如果未能解决你的问题,请参考以下文章