Hyperledger Fabric stand-alone Docker CLI startup and query transfer operation

Source: Internet
Author: User
Tags docker ps docker run hyperledger fabric
Start Fabric

Now that all the files are ready, we can start our fabric network. Start Orderer

Let's start with the Orderer node and run on the Orderer server:

After running, we can use Docker PS to see a node running with a name of orderer.example.com.

[ROOT@IZ2ZEIVRKCKULQ2DTIDZTMZ e2e_cli]# docker-compose-f docker-compose-cli.yaml up warning:the CHANNEL_NAME variable is isn't set.
Defaulting to a blank string. Warning:the TIMEOUT variable is not set.
Defaulting to a blank string. Traceback (most recent): File "/usr/bin/docker-compose", line one, in <module> sys.exit (Main ()) Fil E "/usr/lib/python2.7/site-packages/compose/cli/main.py", line, in main command () File "/usr/lib/python2.7/site-p" ackages/compose/cli/main.py ", line 124, in Perform_command handler (command, command_options) File"/usr/lib/python2. 7/site-packages/compose/cli/main.py ", line 959, in Up Start=not no_start File"/usr/lib/python2.7/site-packages/comp ose/project.py ", line 449, in Up Include_deps=start_deps) File"/usr/lib/python2.7/site-packages/compose/project.py " , line 189, in get_services_without_duplicate services = Self.get_services (Service_names, include_deps) File "/usr/l Ib/python2.7/site-packages/compose/project.py ", line 177, in get_services unsorted = [Self.get_service (name) to name in Service_names] File"/usr/li b/python2.7/site-packages/compose/project.py ", line 148, in Get_service raise Nosuchservice (name) File"/usr/lib/pyt hon2.7/site-packages/compose/project.py ", line 690, in __init__ self.msg =" No Such service:%s "% Self.name Unicodede Codeerror: ' ASCII ' codec can ' t decode byte 0xe2 in position 0:ordinal not in range (128)
Solving method


1 The first: Here we will Python's default encoding to Utf-8, we can circumvent the above problem, in particular, we add the following code in the Python file:

import sys
defaultencoding = ' Utf-8 '
if sys.getdefaultencoding ()!= defaultencoding:
    reload (SYS)
    sys.setdefaultencoding ( defaultencoding) (
 2) The second: we add a sitecustomize.py file in the/usr/lib/python2.7/site-packages/directory, which reads as follows:

Import sys
sys.setdefaultencoding (' utf-8 ')
 this way can solve all the encoding problems of the project, specific instructions can refer to/usr/lib/python2.7/site.py file:


Docker-compose-f Docker-compose-cli.yaml Down



Execute command

Docker run-it CLI Bash
Abnormal:
[ROOT@IZ2ZEIVRKCKULQ2DTIDZTMZ e2e_cli]# Docker exec-it CLI bash
Error response from Daemon:container 1f9b6f7d709f26 3F4A67A67AD91B419B13844EFAAA4CAEB6DD571BFA829822C7 is not running

Workaround:

CLI:
    container_name:cli ...
   Working_dir:/opt/gopath/src/github.com/hyperledger/fabric/peer
   # command:/bin/bash-c './scripts/script.sh ${ Channel_name} ${delay}; Sleep $TIMEOUT '
    volumes:
        -/var/run/:/host/var/run/
...

Comments

Command:/bin/bash-c './scripts/script.sh ${channel_name} ${delay}; Sleep $TIMEOUT '

Enter CLI execution

./scripts/script.sh MyChannel
Inquire

Peer Chaincode query-c mychannel-n mycc-c ' {' Args ': [' query ', ' A ']} '


Transfer

Peer Chaincode invoke-o orderer.example.com:7050  --tls true--cafile/opt/gopath/src/github.com/hyperledger/ fabric/peer/crypto/ordererorganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/ TLSCA.EXAMPLE.COM-CERT.PEM-  C mychannel-n mycc-c ' {"Args": ["Invoke", "a", "B", "20"]} '


Query balance


Resources


http://hyperledger-fabric.readthedocs.io/en/latest/build_network.html?highlight=e2e

Https://www.jianshu.com/p/b34dbb643a70

Https://www.cnblogs.com/studyzy/p/7237287.html

Https://stackoverflow.com/questions/48196669/hyperledger-fabric-cli-container-errors


Welcome to join us in the discussion ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.