351-fabric浅析docker-compose

9333 ワード









fabric  docker-compose






     peer,orderer    
    docker-compose

           docker-compose
    /fabric-samples/first-network

      
abc@abc:~/workspace/fabric/sample/fabric-samples/first-network$ ls
base                     docker-compose-couch-org3.yaml    eyfn.sh
byfn.sh                  docker-compose-couch.yaml         org3-artifacts
channel-artifacts        docker-compose-e2e-template.yaml  README.md
configtx.yaml            docker-compose-etcdraft2.yaml     scripts
crypto-config.yaml       docker-compose-kafka.yaml
docker-compose-cli.yaml  docker-compose-org3.yaml




    docker-compose-cli.yaml
   docker-compose-cli.yaml    






        
docker-compose-cli.yaml



# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: '2'

volumes:
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:
  peer0.org2.example.com:
  peer1.org2.example.com:

networks:
  byfn:

services:

  orderer.example.com:
    extends:
      file:   base/docker-compose-base.yaml
      service: orderer.example.com
    container_name: orderer.example.com
    networks:
      - byfn

  peer0.org1.example.com:
    container_name: peer0.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org1.example.com
    networks:
      - byfn

  peer1.org1.example.com:
    container_name: peer1.org1.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org1.example.com
    networks:
      - byfn

  peer0.org2.example.com:
    container_name: peer0.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer0.org2.example.com
    networks:
      - byfn

  peer1.org2.example.com:
    container_name: peer1.org2.example.com
    extends:
      file:  base/docker-compose-base.yaml
      service: peer1.org2.example.com
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:$IMAGE_TAG
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- FABRIC_LOGGING_SPEC=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/chaincode
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
      - peer0.org2.example.com
      - peer1.org2.example.com
    networks:
      - byfn







       base   
     first-network    base        

abc@abc:~/workspace/fabric$ ls
abc.yaml  channel.tx     crypto-config            genesis.block  template.yaml
base      configtx.yaml  docker-compose-cli.yaml  sample









      docker-compose   cli

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:$IMAGE_TAG
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- FABRIC_LOGGING_SPEC=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
        - /var/run/:/host/var/run/
        - ./../chaincode/:/opt/gopath/src/github.com/chaincode
        - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
        - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
        - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - orderer.example.com
      - peer0.org1.example.com
      - peer1.org1.example.com
      - peer0.org2.example.com
      - peer1.org2.example.com
    networks:
      - byfn





       
1.container_name 	    
2.image				  
3.tty				true,     
4.stdin_open		true,         
5.environment		    
6.working_dir		    
7.command			  bash  
8.volumes			     
9.depends_on		
10.networks			












       
docker images

hyperledger/fabric-tools           1.2.1               7aea1cc899d1        6 months ago        1.51GB
hyperledger/fabric-tools           latest              7aea1cc899d1        6 months ago        1.51GB
hyperledger/fabric-ccenv           1.2.1               8651e7160d88        6 months ago        1.43GB
hyperledger/fabric-ccenv           latest              8651e7160d88        6 months ago        1.43GB
hyperledger/fabric-orderer         1.2.1               b1a1dd788841        6 months ago        152MB
hyperledger/fabric-orderer         latest              b1a1dd788841        6 months ago        152MB
hyperledger/fabric-peer            1.2.1               ef0e7788ead0        6 months ago        159MB
hyperledger/fabric-peer            latest              ef0e7788ead0        6 months ago        159MB
hyperledger/fabric-ca              1.2.1               be8400395e15        6 months ago        251MB
hyperledger/fabric-ca              latest              be8400395e15        6 months ago        251MB
hyperledger/fabric-zookeeper       0.4.10              2b51158f3898        9 months ago        1.44GB
hyperledger/fabric-zookeeper       latest              2b51158f3898        9 months ago        1.44GB
hyperledger/fabric-kafka           0.4.10              936aef6db0e6        9 months ago        1.45GB
hyperledger/fabric-kafka           latest              936aef6db0e6        9 months ago        1.45GB
hyperledger/fabric-couchdb         0.4.10              3092eca241fc        9 months ago        1.61GB
hyperledger/fabric-couchdb         latest              3092eca241fc        9 months ago        1.61GB
hyperledger/fabric-baseos          amd64-0.4.10        52190e831002        9 months ago        132MB










          

    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- FABRIC_LOGGING_SPEC=DEBUG
      - FABRIC_LOGGING_SPEC=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp
  



1.GOPATH						#go   
2.CORE_VM_ENDPOINT				#   
3.FABRIC_LOGGING_SPEC			#    
4.CORE_PEER_ID					#  ID
5.CORE_PEER_ADDRESS				#    
6.CORE_PEER_LOCALMSPID			#  ID
7.CORE_PEER_TLS_ENABLED			#       
8.CORE_PEER_TLS_CERT_FILE		#TLS  
9.CORE_PEER_TLS_KEY_FILE		#TLS  
10.CORE_PEER_TLS_ROOTCERT_FILE 	#TLS   
11.CORE_PEER_MSPCONFIGPATH		#MSP  











leader  
1.peer  
2.     orderer    
3.      ,leader      
4.      leader  
5.    
	1.    ,    leader  ,   leader   
	2.    ,   leader    ,       

- CORE_PEER_GOSSIP_USELEADERELECTION=true 	#      
- CORE_PEER_GOSSIP_ORGLEADER=false			#         leader