TL;DR
What is the correct method for creating a channel in HF? I've tried 4 different approaches, each ending in failure.
Troubleshooting of errors is welcome in the comments, but in this post, what I'd like to ask is what is the correct approach/method/setup to create a channel in Hyperledger Fabric?
Edit Note My original post was asking multiple questions. I've updated this post to focus on the first question and put my second question focusing on troubleshooting a specific approach here.
Approach => Result
- Run channel create on host (no local core.yaml) => core config not found
- Run channel create in Docker container => no fabric binaries (could not execute)
- Run channel create on host (with local core.yaml) => failed to connect to orderer
- Run channel create on host (with linked core.yaml) => failed to start container
Background: I'm building a customized HF network (using the Test Network as a reference). I've setup the CAs, generated the MSPs, started the nodes (1 Peer, 1 Orderer), generated the Orderer genesis block (and then restarted the Orderer node).
I'm using Docker swarm, but so far, I'm only focusing on the first host (which is running the above 4 containers: 2 nodes and respective CAs).
Here's more detail on each approach I've tried:
1. Run channel create from host with no local core.yaml file.
After packaging a channel Tx, I try to create a channel using the following command:
peer channel create -o $host:1050 -c $CHANNEL_NAME --ordererTLSHostnameOverride $ORG -f ./channel-artifacts/${CHANNEL_NAME}.tx --outputBlock ./channel-artifacts/${CHANNEL_NAME}.block --tls --cafile $ORDERER_CA
I get the following error:
020-09-15 16:37:06.186 MST [main] InitCmd -> ERRO 001 Fatal error when initializing core config : Could not find config file. Please make sure that FABRIC_CFG_PATH is set to a path which contains core.yaml
The FABRIC_CFG_PATH is set (by default) to /etc/hyperledger/fabric inside the Peer Docker container (and that path contains an auto-generated core.yaml file), however, I'm guessing that since the channel create command is run on the host, not the docker container, this is why the core config is not found? (However, according to this post, I shouldn't need a local core.yaml file?)
2. Try running channel create commands from inside Docker container (with existing, auto-generated core.yaml file).
I exec'd into the Peer Docker container and ran my create Channel Tx and Create Channel commands directly from the docker container. However, this fails because the docker container does not have the fabric binaries loaded. (I tried doing a read-only bind mount of my fabric-samples/bin to a directory in the docker container's /bin path, but ran into problems and didn't explore it further.)
3. Create local core.yaml file, set FABRIC_CFG_PATH=$PWD and run channel create commands locally.
Resulting error:
Error: failed to create deliver client for orderer: orderer client failed to connect to oem.scm.cloudns.asia:1050: failed to create new connection: context deadline exceeded
This seems to be because the host:port mapping only has significance inside the docker network, NOT on the host machine. (I can successfully ping the host:port and :port from inside my docker Peer container.)
Update: container log for the orderer shows this error:
2020-09-16 19:14:52.165 UTC [core.comm] ServerHandshake -> ERRO 53e TLS handshake failed with error remote error: tls: bad certificate server=Orderer remoteaddress=10.0.0.3:54110
For a similar problem, Gari Singh said that the TLS server certificate SANS was missing the correct address. I tried adding 10.0.0.3 to my docker-compose file for the CA and restarting, but still got the same error.
4. Same as #3, execept time bind mount the local directory containing core.yaml to the Peer Docker container, and try to start channel from host.
When I tried this approach, I ran into problems because the msp path in the core.yaml file either points to the path on my host, or the corresponding docker container internal msp path.
If I point to the Docker internal msp path, then the Channel start command fails (since the command is run from the host). If I point to the Host msp path, the Peer Docker container fails to start because it can't find the path from inside the container.
Based on everything I've tried, I want to know what is the "correct" approach/method/setup for creating a channel in Hyperledger Fabric?