I am trying to run hyperledger fabric using container. Here is my docker-compose yml. docker-compose.yaml

version: '2'

services:

  ca.org1.sample.com:
    image: hyperledger/fabric-ca:1.4
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org1
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.sample.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/0c7af57d616f614fd42250b8ba14a0c777220874d328ecbd1464a47ef3f85b1a_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.sample.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/0c7af57d616f614fd42250b8ba14a0c777220874d328ecbd1464a47ef3f85b1a_sk
    ports:
      - "7054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./channel/crypto-config/peerOrganizations/org1.sample.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg1

  ca.org2.sample.com:
    image: hyperledger/fabric-ca:1.4
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-org2
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.sample.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/fc399b786271e773cc0011593c6bcae7c4b4ae0f4a595ebf0883154bddb4daa7_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.sample.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/fc399b786271e773cc0011593c6bcae7c4b4ae0f4a595ebf0883154bddb4daa7_sk
    ports:
      - "8054:7054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./channel/crypto-config/peerOrganizations/org2.sample.com/ca/:/etc/hyperledger/fabric-ca-server-config
    container_name: ca_peerOrg2

  orderer.sample.com:
    container_name: orderer.sample.com
    image: hyperledger/fabric-orderer:1.4
    environment:
      - FABRIC_LOGGING_SPEC=debug
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/crypto/orderer/msp
      - ORDERER_GENERAL_TLS_ENABLED=true
      - ORDERER_GENERAL_TLS_PRIVATEKEY=/etc/hyperledger/crypto/orderer/tls/server.key
      - ORDERER_GENERAL_TLS_CERTIFICATE=/etc/hyperledger/crypto/orderer/tls/server.crt
      - ORDERER_GENERAL_TLS_ROOTCAS=[/etc/hyperledger/crypto/orderer/tls/ca.crt, /etc/hyperledger/crypto/peerOrg1/tls/ca.crt, /etc/hyperledger/crypto/peerOrg2/tls/ca.crt]
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderers
    command: orderer
    ports:
      - 7050:7050
    volumes:
        - ./channel:/etc/hyperledger/configtx
        - ./channel/crypto-config/ordererOrganizations/sample.com/orderers/orderer.sample.com/:/etc/hyperledger/crypto/orderer
        - ./channel/crypto-config/peerOrganizations/org1.sample.com/peers/peer0.org1.sample.com/:/etc/hyperledger/crypto/peerOrg1
        - ./channel/crypto-config/peerOrganizations/org2.sample.com/peers/peer0.org2.sample.com/:/etc/hyperledger/crypto/peerOrg2

  peer0.org1.sample.com:
    container_name: peer0.org1.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org1.sample.com
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_ADDRESS=peer0.org1.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.sample.com:7051
    ports:
      - 7051:7051
      - 7053:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org1.sample.com/peers/peer0.org1.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

  peer1.org1.sample.com:
    container_name: peer1.org1.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org1.sample.com
      - CORE_PEER_LOCALMSPID=Org1MSP
      - CORE_PEER_ADDRESS=peer1.org1.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.sample.com:7051
    ports:
      - 7056:7051
      - 7058:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org1.sample.com/peers/peer1.org1.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

  peer0.org2.sample.com:
    container_name: peer0.org2.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer0.org2.sample.com
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_ADDRESS=peer0.org2.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.sample.com:7051
    ports:
      - 8051:7051
      - 8053:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org2.sample.com/peers/peer0.org2.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

  peer1.org2.sample.com:
    container_name: peer1.org2.sample.com
    extends:
      file:   base.yaml
      service: peer-base
    environment:
      - CORE_PEER_ID=peer1.org2.sample.com
      - CORE_PEER_LOCALMSPID=Org2MSP
      - CORE_PEER_ADDRESS=peer1.org2.sample.com:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.sample.com:7051      
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.sample.com:7051
    ports:
      - 8056:7051
      - 8058:7053
    volumes:
        - ./channel/crypto-config/peerOrganizations/org2.sample.com/peers/peer1.org2.sample.com/:/etc/hyperledger/crypto/peer
    depends_on:
      - orderer.sample.com

base.yaml file

version: '2'
services:
  peer-base:
    image: hyperledger/fabric-peer:1.4
    environment:
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=artifacts_default
      - FABRIC_LOGGING_SPEC=ERROR
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/msp
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/crypto/peer/tls/server.key
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/crypto/peer/tls/server.crt
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/crypto/peer/tls/ca.crt
    logging:
      driver: "json-file"
      options:
        max-file: "2"
        max-size: "5m"
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: peer node start
    volumes:
        - /var/run/:/host/var/run/

After running these containers, I can not see running ca_peerOrg1 and ca_peerOrg2 containers.

➜  sample_network git:(master) ✗ docker container ps
CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS              PORTS                                            NAMES
17e106be6872        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp   peer0.org2.sample.com
fd72c0b378e3        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp   peer0.org1.sample.com
f0198beef653        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:7056->7051/tcp, 0.0.0.0:7058->7053/tcp   peer1.org1.sample.com
a9d2a0fabe6d        hyperledger/fabric-peer:1.4      "peer node start"   42 seconds ago      Up 35 seconds       0.0.0.0:8056->7051/tcp, 0.0.0.0:8058->7053/tcp   peer1.org2.sample.com
8173c3c09e6a        hyperledger/fabric-orderer:1.4   "orderer"           49 seconds ago      Up 43 seconds       0.0.0.0:7050->7050/tcp                           orderer.sample.com

Here ca_peerOrg1 and ca_peerOrg2 are not running. So When I try to register from node sdk, I am getting the following error,

POST request Enroll on Org1  ...

{"success":false,"message":"failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]"}

ORG1 token is null

POST request Enroll on Org2 ...

{"success":false,"message":"failed Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:8054]"}

ORG2 token is null

Please help me to fix this issue.

1

There are 1 answers

0
myeongkil kim On BEST ANSWER

Check whether the FABRIC_CA_SERVER_CA_KEYFILE and FABRIC_CA_SERVER_TLS_KEYFILE of CA for each organization is properly written. in docker-compose.yaml

# ca_peerOrg1
ls ./channel/crypto-config/peerOrganizations/org1.sample.com/ca/

# ca_peerOrg2
ls ./channel/crypto-config/peerOrganizations/org2.sample.com/ca/

Among the result values operated by the above command, the name of the *_sk file should be written as the FABRIC_CA_SERVER_CA_KEYFILE and FABRIC_CA_SERVER_TLS_KEYFILE

If there are a log according to, I can talk more clearly.

docker logs ca_peerOrg1
docker logs ca_peerOrg2