The location where the CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS=0.0.0.0:7051 ./chaincode_example02 command is run appears to be the key factor.
I can replicate the same results that were experienced by running docker-compose up, obtaining the chaincode_example02 code on the Windows host, building the chaincode on Windows, and then opening a new Docker Quickstart window. I changed directory to the $GOPATH/src/github.com/chaincode_example02 directory and then ran the above command. The results match the results noted in the question.
Running the command from within the Docker container for the peer image should produce different results.
- After running
docker-compose up based on the docker-compose.yml file, open another Docker Quickstart window.
- Navigate into the file system for the peer by using a command similar to this command:
docker exec -it <substitute container name>_vp0_1 bash. To find the container name, you can first run docker ps.
- Once in the peer file system, you can check the ports that are being used by reviewing the /opt/gopath/src/github.com/hyperledger/fabric/peer/core.yaml file. The “listenAddress” for the peer is noted as 0.0.0.0:7051.
- The
netstat -an command can be used to check that port 7051 is in listening state.
- If the peer doesn't seem to be listening on port 7051, make sure that the
peer node start --peer-chaincodedev command has run. This should have happened as a result of the docker-compose.yml file since it is the last statement in that file.
- Navigate to /opt/gopath/src/github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 within the peer file system and run
go build.
- Stay in the same chaincode_example02 directory and run the
CORE_CHAINCODE_ID_NAME=mycc CORE_PEER_ADDRESS:0.0.0.0.7051 ./chaincode_example02 command