Setup Docker

Now that you have verified that you can connect to the Hyperledger Fabric CA, run the following commands to configure the CA client:

mkdir -p ~/go/src/github.com/hyperledger/fabric-ca
cd ~/go/src/github.com/hyperledger/fabric-ca
wget https://github.com/hyperledger/fabric-ca/releases/download/v1.4.6/hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz -O hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz
tar -xzf hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz --overwrite
cd
git clone --branch v1.4.7 https://github.com/hyperledger/fabric-samples.git

Create a configuration file for Docker Compose with the following bash command pasted into your terminal. This will be used to run various Fabric commands.

cd
cat <<EOT > docker-compose-cli.yaml
version: '2'
services:
  cli:
    container_name: cli
    image: hyperledger/fabric-tools:1.4
    tty: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      - FABRIC_LOGGING_SPEC=info # Set logging level to debug for more verbose logging
      - CORE_PEER_ID=cli
      - CORE_CHAINCODE_KEEPALIVE=10
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/home/managedblockchain-tls-chain.pem
      - CORE_PEER_LOCALMSPID=$MEMBERID
      - CORE_PEER_MSPCONFIGPATH=/opt/home/admin-msp
      - CORE_PEER_ADDRESS=$PEER1ENDPOINT
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - $HOME/fabric-samples/chaincode:/opt/gopath/src/github.com/
      - $HOME:/opt/home
EOT

The Fabric command-line interface (CLI) runs inside a docker container. Start up the container with the following command:

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

That should show some output indicating that various docker images are being downloaded. When it’s all done, you should see output like this:

Creating network "ec2-user_default" with the default driver
Pulling cli (hyperledger/fabric-tools:1.2.0)...
1.2.0: Pulling from hyperledger/fabric-tools
b234f539f7a1: Pull complete
55172d420b43: Pull complete
5ba5bbeb6b91: Pull complete
43ae2841ad7a: Pull complete
f6c9c6de4190: Pull complete
c6af77e36488: Pull complete
964f7f4f22f3: Pull complete
13cd31405e09: Pull complete
e03b35c19d96: Pull complete
96c2920985e3: Pull complete
e91461be8304: Pull complete
314928def9dd: Pull complete
d5b68ae13f8d: Pull complete
dde25187799d: Pull complete
Digest: sha256:24cca44a2f2ab6325c6ccc1c91a10bd3e0e71764037a85a473f7e9621b3a0f91
Status: Downloaded newer image for hyperledger/fabric-tools:1.2.0
Creating cli ... done