dockerdocker-composehyperledger-fabrichyperledger

Chaincode deploying fails on Hyperledger Fabric


I'm trying to run the sample test-network from the fabric-samples folder, but for some reason the chaincode installation fails, giving me an error. Here's all I get when trying to run the deployCC command:

    Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image inspection failed: cannot connect to Docker endpoint
Chaincode installation on peer0.org1 has failed
Deploying chaincode failed

$ ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-java -ccl java
deploying chaincode on channel 'mychannel'
executing with the following
- CHANNEL_NAME: mychannel
- CC_NAME: basic
- CC_SRC_PATH: ../asset-transfer-basic/chaincode-java
- CC_SRC_LANGUAGE: java
- CC_VERSION: 1.0
- CC_SEQUENCE: 1
- CC_END_POLICY: NA
- CC_COLL_CONFIG: NA
- CC_INIT_FCN: NA
- DELAY: 3
- MAX_RETRY: 5
- VERBOSE: false
Compiling Java code...
~/Desktop/fabric-samples/asset-transfer-basic/chaincode-java ~/Desktop/fabric-samples/test-network
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons could not be reused, use --status for details
<-------------> 0% INITIALIZING [118ms]
<-------------> 0% INITIALIZING [627ms]
<-------------> 0% CONFIGURING [919ms]
<-------------> 0% CONFIGURING [2s]
> root <==-----------> 20% EXECUTING [3s]
> r<======-------> 53% EXECUTING [3s]
<===========--> 86% EXECUTING [4s]tRuntimeClasspath

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 12s
10 actionable tasks: 2 executed, 8 up-to-date
~/Desktop/fabric-samples/test-network
Finished compiling Java code
+ peer lifecycle chaincode package basic.tar.gz --path ../asset-transfer-basic/chaincode-java/build/install/basic --lang java --label basic_1.0
+ res=0
Chaincode is packaged
Installing chaincode on peer0.org1...
Using organization 1
+ peer lifecycle chaincode install basic.tar.gz
+ res=1
Error: chaincode install failed with status: 500 - failed to invoke backing implementation of 'InstallChaincode': could not build chaincode: docker build failed: docker image inspection failed: cannot connect to Docker endpoint
Chaincode installation on peer0.org1 has failed
Deploying chaincode failed

I'm running this on Docker for Windows, and unfortunately all the helpful answers I've found on the Internet are related to turning the gRPC feature off, which isn't supported in Windows.

Any help would be appreciated, I've tried to uninstall everything (including binaries) and reinstalling, but no luck for the last 2 days.

Setting up the network and channel creation works without errors/warnings, so I'm guessing it's a docker-related communication problem.


Solution

  • The problem is that the test-network uses the inbuilt chaincode builder and launcher which requires access to your docker on windows setup. The error being reported is that it cannot connect to it.

    If you are using the main branch of fabric-samples then can try to set the DOCKER_SOCK environment variable before bringing up the test-network in your window shell. Take a look at https://docs.docker.com/desktop/faqs/ to see what you can set it to. Also look at the option to expose the docker daemon on an unsecure port which might help.

    The DOCKER_SOCK option was added to fabric-samples in main but doesn't appear to be in the 2.2 branch so be aware you aren't using a fabric LTS release here

    The caveat is I've not tried this so no guarantees it will work

    Unfortunately Windows is not given much attention at the moment for using fabric so the best advice I can give you at this time would be to use linux instead as your platform (you can use WSL2 but you should google installing docker into a WSL2 distro as it does require a bit of extra work)