Coder Social home page Coder Social logo

docker-hyperledger-peer's Introduction

Docker-Hyperledger-Peer

Docker images for Hyperledger fabric peer.

Supported tags and respective Dockerfile links

For more information about this image and its history, please see the relevant manifest file in the yeasy/docker-hyperledger-peer GitHub repo.

If you want to quickly deploy a local cluster without any configuration and vagrant, please refer to hyperledger-compose-files.

What is docker-hyperledger-peer?

Docker image with hyperledger fabric peer deployed.

How to use this image?

The docker image is auto built at https://registry.hub.docker.com/u/yeasy/hyperledger-peer/.

In Dockerfile

FROM yeasy/hyperledger-peer:latest

Local Run

The peer command is already there, add your sub command and flags at the end.

E.g., see the supported sub commands with the help command.

02:10:10.359 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO


Usage:
  peer [command]

Available Commands:
  node        node specific commands.
  network     network specific commands.
  chaincode   chaincode specific commands.
  help        Help about any command

Flags:
      --logging-level="": Default logging level and overrides, see core.yaml for full syntax


Use "peer [command] --help" for more information about a command.

Hyperledger relies on a core.yaml file, you can mount your local one by

$ docker run -v your_local_core.yaml:/go/src/github.com/hyperledger/fabric/peer/core.yaml -d yeasy/hyperledger-peer node start help

The storage will be under /var/hyperledger/, which should be mounted from host for persistent requirement.

Your can also mapping the port outside using the -p options.

  • 5000: REST service listening port (Recommened to open at non-validating node)
  • 30303: Peer service listening port
  • 30304: CLI process use it for callbacks from chain code
  • 31315: Event service on validating node

Local Run with chaincode testing

Start your docker daemon with

$ sudo docker daemon --api-cors-header="*" -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

Pull necessary images, notice the default config require a local built openblockchain/baseimage. We can just use the yeasy/hyperledger image instead.

$ docker pull yeasy/hyperledger:latest
$ docker tag yeasy/hyperledger:latest hyperledger/fabric-baseimage:latest
$ docker pull yeasy/hyperledger-peer:latest
$ docker pull yeasy/hyperledger-peer:noops
$ docker pull yeasy/hyperledger-peer:pbft

Check the docker0 bridge ip, normally it should be 172.17.0.1. This ip will be used as the CORE_VM_ENDPOINT=http://172.17.0.1:2375.

$  ip addr show dev docker0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:f2:90:57:cf brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
    valid_lft forever preferred_lft forever
    inet6 fe80::42:f2ff:fe90:57cf/64 scope link
    valid_lft forever preferred_lft forever

Start a validating node.

Noops consensus

$ docker run --name=vp0 \
                    --restart=unless-stopped \
                    -it \
                    -p 5000:5000 \
                    -p 30303:30303 \
                    -e CORE_PEER_ID=vp0 \
                    -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 \
                    -e CORE_PEER_ADDRESSAUTODETECT=true \
                    -e CORE_NOOPS_BLOCK_TIMEOUT=10 \
                    yeasy/hyperledger-peer:noops peer node start

PBFT consensus

PBFT requires at least 4 nodes, so please refer to hyperledger-compose-files.

After the cluster starts up, enter into the container

$ docker exec -it vp0 bash

Inside the container, deploy a chaincode using

$ peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}'
13:16:35.643 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO
5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5

Query a's current value, which is 100.

$ peer chaincode query -n 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 -c '{"Function": "query", "Args": ["a"]}'
13:20:07.952 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO
100

Invoke a transaction of 10 from a to b.

$ peer chaincode invoke -n 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 -c '{"Function": "invoke", "Args": ["a", "b", "10"]}'
13:20:31.028 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO
ec3c675b-a2fe-4429-ab44-7f389e454657

Query a 's value now.

$ peer chaincode query -n 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 -c '{"Function": "query", "Args": ["a"]}'
13:20:35.725 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO
90

More examples, please refer to hyperledger-compose-files.

Which image is based on?

The image is built based on hyperledger base image.

What has been changed?

install dependencies

Install required libsnappy-dev, zlib1g-dev, libbz2-dev.

install rocksdb

Install required rocksdb 4.1.

install hyperledger

Install hyperledger and build the peer

Supported Docker versions

This image is officially supported on Docker version 1.7.0.

Support for older versions (down to 1.0) is provided on a best-effort basis.

Known Issues

  • N/A.

User Feedback

Documentation

Be sure to familiarize yourself with the repository's README.md file before attempting a pull request.

Issues

If you have any problems with or questions about this image, please contact us through a GitHub issue.

You can also reach many of the official image maintainers via the email.

Contributing

You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.

docker-hyperledger-peer's People

Contributors

yeasy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.