[Solved] Fabric 2.x: error starting container: API error (404): network_test not found

Run fabric samples/test network example with fabric 2.2, and the network error is as follows:

Error: endorsement failure during invoke. 
response: status:500 message:"error in simulation: failed to execute transaction 18cf3086eb32e877a497fe3cb33a4d0d0dc892f221528bf0788a07d4ffb6bdcf: could not launch 
chaincode fabcar_1:762e0fe3dbeee0f7b08fb6200adeb4a3a20f649a00f168c0b3c2257e53b6e506: error starting container: error starting container:
API error (404): network _test not found" 

The possible reason is that the update of docker compose Version (+ after v1.28) causes problems in reading .Env files.

As shown in the figure below, network.Sh script will call docker compose to start the container. Originally, docker compose should read the .Env environment variable according to the compose in it_PROJECT_Name = net generates a net_Test , but reading .Env failed, which is equivalent to not reading the value of net , so the in the error message is generated_test not found

Solution:
first ./network.sh down drop the network down . Manually modify the network.Sh file, add -- env file./.Env at the command of docker compose , and explicitly specify to read the environment variable configuration file, as shown in the following figure


restart the network for experiment

Read More: