Linux搭建Hyperledger Fabric私网遇7050端口占用报错求助
Answer:
Hey there, let's get your Hyperledger Fabric network up and running smoothly by fixing that port conflict. The issue is that host port 7050 is being held by a docker-proxy process, which is tied to another Docker container or leftover network setup. Here are two straightforward solutions:
Option 1: Reconfigure the First-Network to Use a Different Host Port
Since you're working with the first-network sample, adjusting the port mapping for the orderer service is a safe approach:
Edit the base Docker Compose configuration
Open thedocker-compose-base.ymlfile in yourfirst-networkdirectory:sudo nano docker-compose-base.ymlLocate the
orderer.example.comservice section and find theportsline. It will look like this:ports: - "7050:7050"Change the first number (this is the host port) to an unused port, like
7055:ports: - "7055:7050"The second number is the internal container port, which doesn't need to change—containers in the same network will still communicate with the orderer on port 7050.
Clean up failed network artifacts
Before restarting, make sure to remove any leftover containers, volumes, and networks from your previous attempt:sudo ./byfn.sh downStart the network again
Run the up command once more, and it should use the new port without conflict:sudo ./byfn.sh up
Option 2: Stop the Container Holding Port 7050
If you prefer to keep using port 7050, you can identify and stop the container that's causing the docker-proxy to reserve the port:
Find the conflicting container
List all running containers and check which one is mapped to port 7050:sudo docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" | grep 7050If that doesn't return a result, check for leftover containers (even stopped ones) that might be holding the port:
sudo docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" | grep 7050Remove the conflicting container
Once you have the container name or ID, stop and remove it:sudo docker stop <container-name-or-id> sudo docker rm <container-name-or-id>Clean up and restart
Again, clean up any residual Fabric network components and start fresh:sudo ./byfn.sh down sudo ./byfn.sh up
Important Note:
Never kill the docker-proxy process directly (PID 3682 in your case). Docker manages these proxy processes automatically, and manually killing them can break network connectivity for other containers. Always use Docker's built-in commands to manage containers and ports.
内容的提问来源于stack exchange,提问作者Alaa Halabi

