Error when try to instantiate chain-code on Hyperledger Fabric
So, the issue here is with the COMPOSE_PROJECT_NAME env. When I try to start my network form the folder with network specification this env remains empty for some reason and I get the aforementioned error. When I copy my network specification to /fabric-samples/firtst-network folder and try to start it again the COMPOSE_PROJECT_NAME got set to "net" value and everything works fine. Also when I try to hardcode this value to "net" in /base/peer-base.yaml and try to start the network again from the default folder, I get the time-out ERR on peer.
EDIT1:
The final answer will be: I have not setup .env file for the aforementioned env. variable within the folder.
In my case in .env
file I had defined
COMPOSE_PROJECT_NAME=xxx
and in docker-compose.yml file I had
version: '2'
networks:
yyy: <----------------
services:
...
...
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=zzz
...
...
At some point I run to same issue
failed to invoke chaincode name:"lscc" , error: API error (404): network zzz not found
Listing docker networks (docker network ls
) shows that network with name xxx_yyy
is created so basically changing value of CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
to xxx_yyy
solve issue in my case.
CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=xxx_yyy
By inspecting the error from the log file you've provided:
peer0.org1.example.com | 2017-10-16 15:59:46.745 UTC [dockercontroller] Start -> ERRO 3d9 start-could not start container: API error (404): {"message":"network _byfn not found"}
It seems that network name has unintentional space character network _byfn
, hence I'd guess you need to fix it in docker-compose.yaml
file:
Check value of CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
environment variable, you can find it in base/peer-base.yaml
:
version: '2'
services:
peer-base:
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
# the following setting starts chaincode containers on the same
# bridge network as the peers
# https://docs.docker.com/compose/networking/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_byfn
#- CORE_LOGGING_LEVEL=ERROR
- CORE_LOGGING_LEVEL=DEBUG
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_PROFILE_ENABLED=true
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
Also you can check .env
file content, usually it suppose to be:
COMPOSE_PROJECT_NAME=net