You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行Hyperledger Composer开发者教程时startFabric.sh启动失败求助

Fixing Hyperledger Composer Peer Container Exit (Status Code 2) on Ubuntu 16.04

Hey there, let's work through that peer container exit issue you're hitting when running startFabric.sh for Hyperledger Composer. Exit code 2 usually points to a configuration mismatch, missing dependencies, or resource conflict—here's how to diagnose and fix it:

Step 1: Get Detailed Error Logs

First, let's pull the logs from the failed peer container to pinpoint the exact problem. Run either of these commands (using the container ID or name):

docker logs d2a4df088573
# OR
docker logs peer0.org1.example.com

The logs will tell you if it's a port conflict, missing MSP files, memory issue, or something else—this is the most critical step to narrow down the root cause.

Step 2: Try These Common Fixes

Based on typical issues with this setup, here are the most likely solutions:

Clean Up Stale Fabric Containers & Images

Residual containers or corrupted images often cause startup failures. Run these commands to wipe old resources, then re-run startFabric.sh:

# Stop all running containers
docker stop $(docker ps -aq)
# Delete all containers
docker rm $(docker ps -aq)
# Remove dev images generated by Composer
docker rmi $(docker images dev-* -q)

Verify Sufficient System Memory

Hyperledger Fabric requires at least 2GB of available memory to run properly. Check your system's memory with:

free -h

If you're low on memory, close unused applications or add more RAM to your system.

Check for Port Conflicts

The peer container uses ports 7051 and 7052 by default. Verify these ports aren't being used by another process:

netstat -tulpn | grep -E "7051|7052"

If you see a process using these ports, kill it with sudo kill <PID> (replace <PID> with the process ID) or modify the Fabric configuration to use alternative ports.

Reset Fabric Configuration

Sometimes old configuration files get corrupted. Navigate to your fabric-dev-servers directory, delete the existing config artifacts, and re-initialize:

cd ~/fabric-dev-servers
rm -rf composer-config/
# Re-run the initialization steps from the tutorial
./downloadFabric.sh
./startFabric.sh

Check Firewall Settings

Ubuntu's UFW firewall might be blocking Fabric's required ports. Temporarily disable it to test:

sudo ufw disable

If the peer starts successfully, re-enable the firewall and add rules to allow Fabric ports:

sudo ufw enable
sudo ufw allow 7050/tcp
sudo ufw allow 7051/tcp
sudo ufw allow 7054/tcp
sudo ufw allow 5984/tcp

Step 3: Address Specific Log Errors

If the logs show a specific error like failed to get local MSP config, fix the permissions on your Fabric directories:

chmod -R 755 ~/fabric-dev-servers/

This ensures the peer container can access the necessary MSP (Membership Service Provider) files.


内容的提问来源于stack exchange,提问作者Julien Pradier

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 10:02:31