Block chain Hyperledger fabric environment to build CENTOS7 Docker environment

Source: Internet
Author: User
Tags docker ps hyperledger fabric

Operating Environment CENTOS7 64-bit

1. CentOS Docker Installation

Yum-y Install Docker-io

2. Start Docker Service

Start: Service Docker start

Boot from: Chkconfig Docker on

View Docker versions: Docker version

3. Installation container compose:

Curl-l' uname-s '-' uname-m ' >/usr/ Local/bin/docker-compose
chmod +x/usr/local/bin/docker-compose

View the version number and display version information if the installation is successful:

Docker-compose version

4.docker Pull



Docker tag Yeasy/hyperledger-fabric:0.6-dphyperledger/fabric-peer:latest #给镜像加标记
Docker tag YEASY/HYPERLEDGER-FABRIC:0.6-DP hyperledger/fabric-baseimage:latest
Docker tag YEASY/HYPERLEDGER-FABRIC:0.6-DP hyperledger/fabric-membersrvc:latest

Create a docker-compose.yml in the working directory

The contents are as follows:

Command:sh-c "Sleep 5; Peer node start--peer-chaincodedev "

Running Compose mirrors

Docker-compose up-d

To view a running mirror

Docker PS

Enter Docker

Docker-compose exec  dockername bash
Peer Chaincode deploy-p ' {' Function ': ' Init "," Args ": [" a "," M "," B "," 200 "]} '
(Parameter annotation-P: Specify Chaincode source path;-C: JSON format Shaincode code to execute)

The Chaincode name hash value is returned in the following figure red box, which means that the regional chain has been established successfully. The following can be tested and validated by CLI or post.

Compiling code


CP chaincode_example02/chaincode_example02.go $GOPATH/src/#复制目录里面的例2到 compiled $GOPATH/src/


Go build./chaincode_example02.go #编译成功会在GOPATH/src directory generation CHAINCODE_EXAMPLE02 file

(Chaincode_example02.go Source Link CHAINCODE_EXAMPLE02/CHAINCODE_EXAMPLE02.GO)

b) Release Chaincode run under GOPATH/SRC

CORE_CHAINCODE_ID_NAME=MYCC core_peer_address=

Until the word "Received registered" appeared, the representative succeeded.

Block chain test:

I'm using the Restclient plugin installed by Firefox browser.

1. Login

Post Http://

"Enrollid": "Jim",
"Enrollsecret": "6avzqlwcue9b"

2. Deploy (Deployment)

Post Http://


"Jsonrpc": "2.0",

"Method": "Deploy",

"Params": {

' Type ': 1,

"Chaincodeid": {

' Name ': ' MYCC '


"Ctormsg": {

"Function": "Init",

"Args": ["a", "1000", "B", "2000"]


"Securecontext": "Jim"


"id": 1


3. Invoke (Call)

Post Http://

"Jsonrpc": "2.0",
"Method": "Invoke",
"Params": {
' Type ': 1,
"Chaincodeid": {
' Name ': ' MYCC '
"Ctormsg": {
"Function": "Invoke",
"Args": [
"Securecontext": "Jim"
"ID": 3

Regional information Query

Rest Way (Get HOST:7050/CHAIN/BLOCKS/1):

Host:7050/chain/blocks/0 is the Genesis block.

HOST:7050/CHAIN/BLOCKS/1 the first block, which was built when the DePoy was deployed

HOST:7050/CHAIN/BLOCKS/2 the second block, which was created when invoke transaction was invoked

To exit outside the mirror without closing the mirror:


Close Docker

Docker Stop Dockername

Note: If the above operation appears inexplicable problem, the first use of simple and rude way to restart the host, if not resolved, in the other way.

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: 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.