简体   繁体   English

在 Hyperledger Fabric 上部署链码失败

[英]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.我正在尝试从 fabric-samples 文件夹运行示例测试网络,但由于某种原因链码安装失败,给我一个错误。 Here's all I get when trying to run the deployCC command:这是我尝试运行deployCC命令时得到的全部信息:

    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.我在 Docker for Windows 上运行它,不幸的是,我在 Internet 上找到的所有有用答案都与关闭 gRPC 功能有关,Windows 不支持该功能。

Any help would be appreciated, I've tried to uninstall everything (including binaries) and reinstalling, but no luck for the last 2 days.任何帮助将不胜感激,我尝试卸载所有内容(包括二进制文件)并重新安装,但过去 2 天没有运气。

Setting up the network and channel creation works without errors/warnings, so I'm guessing it's a docker-related communication problem.设置网络和通道创建工作没有错误/警告,所以我猜这是一个与 docker 相关的通信问题。

The problem is that the test-network uses the inbuilt chaincode builder and launcher which requires access to your docker on windows setup.问题是测试网络使用内置的链码构建器和启动器,这需要在 Windows 设置上访问您的 docker。 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.如果您使用的是fabric-samples 的主分支,那么可以尝试在窗口 shell 中启动测试网络之前设置 DOCKER_SOCK 环境变量。 Take a look at https://docs.docker.com/desktop/faqs/ to see what you can set it to.看看https://docs.docker.com/desktop/faqs/看看你可以设置什么。 Also look at the option to expose the docker daemon on an unsecure port which might help.另请查看在不安全端口上公开 docker 守护程序的选项,这可能会有所帮助。

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 DOCKER_SOCK 选项已添加到主要的fabric-samples 中,但似乎不在 2.2 分支中,因此请注意您在此处未使用fabric LTS 版本

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)不幸的是,Windows 目前在使用 Fabric 方面并没有得到太多关注,所以我现在可以给你的最好建议是使用 linux 作为你的平台(你可以使用 WSL2,但你应该谷歌将 docker 安装到 WSL2 发行版中,因为它确实需要一些额外的工作)

Thank you @Gelu , @david_k谢谢@Gelu,@david_k

The problem was that Docker did not expose the containers correctly to the Git-bash CLI I was using(...)问题是 Docker 没有将容器正确地暴露给我正在使用的 Git-bash CLI(...)

SO, I tried WSL2: it took me just about 30 minutes to set Ubuntu, install Hyperledger and GO in it and get the sample chaincode up and running!所以,我尝试了 WSL2:我只花了大约 30 分钟来设置 Ubuntu、安装 Hyperledger 并在其中运行并启动并运行示例链代码!

I did not re-install Docker.我没有重新安装 Docker。 I am using Docker Desktop version 4.1.1 (69879), which in Settings-->Resources-->WSL INTEGRATION has an amazing feature of exposing the containers to all WSL-installed distros(!!!).我正在使用 Docker 桌面版本 4.1.1 (69879),它在设置-->资源-->WSL 集成中有一个惊人的功能,可以将容器暴露给所有 WSL 安装的发行版(!!!)。

The test chaincode runs fast and very smoothly since the very first attempt!自第一次尝试以来,测试链代码运行得非常快且非常流畅!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Hyperledger Fabric byfn 实例化失败 - 链码存在 - Hyperledger Fabric byfn instantiate fails - chaincode exists Hyperledger Fabric 网络中的链码问题 - Chaincode problem in Hyperledger fabric network 如何更新Hyperledger Fabric中的链码? - How to update the chaincode in Hyperledger Fabric? 创建了Docker映像,但是使用Java-SDK实例化Hyperledger Fabric中的链码后容器无法启动 - Docker image is created, however container fails to launch on instantiating the chaincode in Hyperledger Fabric using Java-SDK Hyperledger Fabric Chaincode开发人员模式连接错误 - hyperledger fabric chaincode dev mode connection error 无法使用 hurley hyperledger fabric 安装链码 - cannot install chaincode using hurley hyperledger fabric 如何在 Hyperledger Fabric 中检索当前链码版本? - How do I retrieve current chaincode version in Hyperledger Fabric? 使用 hyperledger fabric 调用链代码:在 $PATH\": unknown" 中找不到可执行文件 - Invoking chaincode with hyperledger fabric: Executable file not found in $PATH\ ": unknown" 如何在Hyperledger Fabric Chaincode容器中设置环境变量 - how to Set environment variable in hyperledger fabric chaincode container Hyperledger Fabric-商业用纸教程-链码实例化错误 - Hyperledger Fabric - Commercial Paper tutorial - chaincode instantiate error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM