Start the Docker containers

We are now ready to run our network, but first we need to perform one last step—editing the compose-cli.yaml.

This file defines the networks and services including the peerorder, and cli containers, the last of which is where you issue commands that interact with the peers (creating channels, deploying Chaincode, and so on).

Below is an example of a docker-compose-cli.yaml:

version: '2'
networks: #Define blockchain network name
fscn:
#service section define all peers service and related container services:
#name of service will serve as an orderer in the fabric network
orderer.fsc.com:
extends:
file: base/docker-compose-base.yaml
service: orderer.fsc.com
container_name: orderer.fsc.com
networks:
- fscn
peer0.org1.fsc.com:
container_name: peer0.org1.fsc.com
extends:
file: base/docker-compose-base.yaml
service: peer0.org1.fsc.com
networks:
- fscn
peer1.org1.fsc.com:
container_name: peer1.org1.fsc.com
extends:
file: base/docker-compose-base.yaml
service: peer1.org1.fsc.com
networks:
- fscn
....
#client section
cli:
container_name: cli
image: hyperledger/fabric-tools
tty: true

Defining environment variable environment:

 - GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
#- CORE_LOGGING_LEVEL=INFO
- CORE_PEER_ID=cli
- CORE_PEER_ADDRESS=peer0.org1.fsc.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.fsc.com/peers/peer0.org1.fsc.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.fsc.com/peers/peer0.org1.fsc.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.fsc.com/peers/peer0.org1.fsc.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.fsc.com/users/[email protected]/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash -c './scripts/script.sh ${CHANNEL_NAME} ${DELAY}; sleep $TIMEOUT'

Mapping the directories that are being used in the environment configurations:

 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.fsc.com
- peer0.org1.fsc.com
- peer1.org1.fsc.com
- peer0.org2.fsc.com
- peer1.org2.fsc.com
- peer0.org3.fsc.com
- peer1.org3.fsc.com
networks:

We define the following environment variables:

CHANNEL_NAME=$CHANNEL_NAME 
TIMEOUT=$CLI_TIMEOUT
DELAY=$CLI_DELAY

The first variable, CHANNEL_NAME, holds the name of the channel that was specified earlier as an input for the configtxgen tool. For the timeout, you can provide a value (specified in seconds), otherwise the CLI container, by default, will exit after 60 seconds.

Finally, we can launch our network by calling the docker-compose command with the docker-compose-cli.yaml file, as follows:

sudo docker-compose -f docker-compose-cli.yaml up

If we run the command, it will launch our network, shown as follows:

To check if everything is running successfully, you can use docker ps to list the executing containers (peers, orderer, and CLI).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset