Overview of Hyperledger Fabric Docker composer configuration files

Hyperledger Fabric utilizes Docker compose to define fabric application services. The docker-compose-cli.yaml service section is the place for defining all peer services and related containers. Hyperledger Fabric's first-network provides a .yaml template to help you quickly start to create yaml files from scratch:

https://github.com/hyperledger/fabric-samples/tree/release-1.2/first-network.

In docker-compose-cli.yaml, we define the following information:

  • networks: Definition of the blockchain network name. In our case, it is icn
  • services: Definition of all peer services and related Docker containers
  • cli: Definition of the Cli container that is used to replace the SDK client, and environment variables for Docker compose command-line behavior

Here is an example configuration for the network and service section:

networks:
icn:
services:
orderer.ic.com:
extends:
file: base/docker-compose-base.yaml
service: orderer.ic.com
container_name: orderer.ic.com
networks:
- icn
peer0.org1.ic.com:
container_name: peer0.org1.ic.com
extends:
file: base/docker-compose-base.yaml
service: peer0.org1.ic.com
networks:
- icn

As you can see, there is a file extension directory: base/docker-compose-base.yaml. Docker compose supports sharing common configuration for individual services with the extends field. We will discuss more on docker-compose-base.yaml later.

Here is an example of configuration for cli section:

cli:
container_name: cli
image: hyperledger/fabric-tools
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_ID=cli
- CORE_PEER_ADDRESS=peer0.org1.ic.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.ic.com/peers/peer0.org1.ic.com/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.ic.com/peers/peer0.org1.ic.com/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.ic.com/peers/peer0.org1.ic.com/tls/ca.crt
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.ic.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'
#for 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.ic.com
- peer0.org1.ic.com
- peer0.org2.ic.com
- peer0.org3.ic.com
networks:
- icn

The docker-compose tool uses the docker-compose-cli.yaml file to initialize the fabric runtime environment. Blow are some of the most common commands you will use when using docker-compose-cli.yaml file:

TTY

TTY basically means a console, and we set it as true.

Image

Points to the fabric-tools image directory.

 

Environment

Specifies environment variables, for example, GOPATH, a TLS-related file location generated by the cryptogen tool.

working_dir

Sets the working directory for the peer.

command

Specifies the command that is issued when the container starts.

volumes

Maps the directories that are being used in the environment configurations.

depends_on

Starts services in dependency order.

 

It then generates four fabric-peer transaction node containers, one fabric-order orderer node container, and one fabric-tools cli container.

..................Content has been hidden....................

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