docker-compose-cli.yaml详解(进入cli容器后踩到深坑的我)(orderer容器未正常启动)

先说我踩得什么坑吧
(重新编辑此博客,以前写的太low)

  • 配置文件详解
  • cli容器中执行遇到的错误

docker-compose-cli.yaml详解:

version: '2'

volumes:   #声明挂载的卷
  orderer.example.com:
  peer0.org1.example.com:
  peer1.org1.example.com:
  peer0.org2.example.com:
  peer1.org2.example.com:

networks:   #声明一个名称为byfn的网络
  byfn:

services:

  orderer.example.com:   #定义一个名称为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        #指定go的路径
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- FABRIC_LOGGING_SPEC=DEBUG
      - FABRIC_LOGGING_SPEC=INFO   #日志级别
      - CORE_PEER_ID=cli      #当前节点的Id
      - CORE_PEER_ADDRESS=peer0.org1.example.com:7051   #以下与peer-base.yaml相同,表示当前客户端容器默认与peer0.org1.example.com进行交互
      - 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    #TLS-peer0.org1.example.com的证书路径
      - 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  #TLS-peer0.org1.example.com的密钥路径
      - 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    #TLS-peer0.org1.example.com的根证书路径
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp  @#TLS-组织1中Admin的MSP路径
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer      #工作目录,即进入容器所在的默认位置
    command: /bin/bash     #启动容器后所运行的第一条命令:使用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

cli容器中遇到的错误:

1、InitCmd -> ERRO 001 Cannot run peer because cannot init crypto, specified path "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp" does not exist or cannot be accessed: stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/[email protected]/msp: no such file or directory
还未解决。。。。

2、Error: failed to create deliver client for orderer: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp: lookup orderer.example.com on 127.0.0.11:53: no such host"
原因:
(1)之前搭建的网络没有清除干净,退出cli容器:exit;清除网络:./byfn.sh -m down;重新启动网络进入cli容器
(2)调出orderer节点的容器日志:docker logs orderer.example.com
docker-compose-cli.yaml详解(进入cli容器后踩到深坑的我)(orderer容器未正常启动)_第1张图片
可以看出是kafka版本的设置问题(Kafka.Version unset, setting to 0.10.2.0),至于kafka版本,如果不设置的默认的就是0.10.2.0.为什么会出现这种情况,我也不是很清楚,大佬路过还请指教一二。。。。
解决方法就是去更改kafka的版本。kafka版本控制的文件是/fabric-samples/config/orderer.yaml在这里插入图片描述

你可能感兴趣的:(fabric)