├── Dockerfile └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile for Hyperledger peer image. This actually follow hyperledger 2 | # image and add default start cmd 3 | # Data is stored under /var/hyperledger/db and /var/hyperledger/production 4 | 5 | FROM yeasy/hyperledger:latest 6 | MAINTAINER Baohua Yang 7 | 8 | CMD ["peer","node","start"] 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Docker-Hyperledger-Peer 2 | === 3 | **This is deprecated, pls see [hyperledger-fabric-peer]((https://github.com/yeasy/docker-hyperledger-fabric-peer).** 4 | 5 | Docker images for [Hyperledger](https://www.hyperledger.org) fabric peer. 6 | 7 | # Supported tags and respective Dockerfile links 8 | 9 | * [`latest` (latest/Dockerfile)](https://github.com/yeasy/docker-hyperledger-peer/blob/master/Dockerfile): Default to enable pbft as consensus. 10 | * [`0.5-dp` (0.5-dp/Dockerfile)](https://github.com/yeasy/docker-hyperledger-peer/blob/0.5-dp/Dockerfile): Use 0.5-developer-preview branch code. 11 | * [`0.6-dp` (0.6-dp/Dockerfile)](https://github.com/yeasy/docker-hyperledger-peer/blob/0.6-dp/Dockerfile): Use 0.6-developer-preview branch code. 12 | 13 | For more information about this image and its history, please see the relevant manifest file in the [`yeasy/docker-hyperledger-peer` GitHub repo](https://github.com/yeasy/docker-hyperledger-peer). 14 | 15 | If you want to quickly deploy a local cluster without any configuration and vagrant, please refer to [Start hyperledger clsuter using compose](https://github.com/yeasy/docker-compose-files#hyperledger). 16 | 17 | # What is docker-hyperledger-peer? 18 | Docker image with hyperledger fabric peer deployed. 19 | 20 | # How to use this image? 21 | The docker image is auto built at [https://registry.hub.docker.com/u/yeasy/hyperledger-peer/](https://registry.hub.docker.com/u/yeasy/hyperledger-peer/). 22 | 23 | ## In Dockerfile 24 | ```sh 25 | FROM yeasy/hyperledger-peer:latest 26 | ``` 27 | 28 | ## Local Run with single node 29 | The `peer` command is the main command, you can use it as the start part. 30 | 31 | E.g., see the supported sub commands with the `help` command. 32 | ```sh 33 | $ peer help 34 | 02:10:10.359 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO 35 | 36 | 37 | Usage: 38 | peer [command] 39 | 40 | Available Commands: 41 | node node specific commands. 42 | network network specific commands. 43 | chaincode chaincode specific commands. 44 | help Help about any command 45 | 46 | Flags: 47 | --logging-level="": Default logging level and overrides, see core.yaml for full syntax 48 | 49 | 50 | Use "peer [command] --help" for more information about a command. 51 | ``` 52 | 53 | Hyperledger relies on a `core.yaml` file, you can mount your local one by 54 | ```sh 55 | $ docker run -v your_local_core.yaml:/go/src/github.com/hyperledger/fabric/peer/core.yaml -d yeasy/hyperledger-peer peer node start help 56 | ``` 57 | 58 | The storage will be under `/var/hyperledger/`, which should be mounted from host for persistent requirement. 59 | 60 | Your can also mapping the port outside using the `-p` options. 61 | 62 | * 7050: REST service listening port (Recommened to open at non-validating node) 63 | * 7051: Peer service listening port 64 | * 7052: CLI process use it for callbacks from chain code 65 | * 7053: Event service on validating node 66 | 67 | ## Local Run with chaincode testing 68 | 69 | Start your docker daemon with 70 | 71 | ```sh 72 | $ sudo docker daemon --api-cors-header="*" -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock 73 | ``` 74 | 75 | Pull necessary images, notice the default config require a local built `openblockchain/baseimage`. We can just use the `yeasy/hyperledger` image instead. 76 | 77 | ```sh 78 | $ docker pull yeasy/hyperledger:latest 79 | $ docker tag yeasy/hyperledger:latest hyperledger/fabric-baseimage:latest 80 | $ docker pull yeasy/hyperledger-peer:latest 81 | ``` 82 | 83 | 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`. 84 | ```sh 85 | $ ip addr show dev docker0 86 | 4: docker0: mtu 1500 qdisc noqueue state DOWN group default 87 | link/ether 02:42:f2:90:57:cf brd ff:ff:ff:ff:ff:ff 88 | inet 172.17.0.1/16 scope global docker0 89 | valid_lft forever preferred_lft forever 90 | inet6 fe80::42:f2ff:fe90:57cf/64 scope link 91 | valid_lft forever preferred_lft forever 92 | ``` 93 | 94 | Start a validating node. 95 | 96 | ### Noops consensus 97 | 98 | ```sh 99 | $ docker run --name=vp0 \ 100 | --restart=unless-stopped \ 101 | -it \ 102 | -p 7050:7050 \ 103 | -p 7051:7051 \ 104 | -v /var/run/docker.sock:/var/run/docker.sock \ 105 | -e CORE_PEER_ID=vp0 \ 106 | -e CORE_PEER_ADDRESSAUTODETECT=true \ 107 | -e CORE_NOOPS_BLOCK_TIMEOUT=10 \ 108 | yeasy/hyperledger-peer:latest peer node start 109 | ``` 110 | 111 | Or use your docker daemon url. 112 | 113 | ```sh 114 | $ docker run --name=vp0 \ 115 | --restart=unless-stopped \ 116 | -it \ 117 | -p 7050:7050 \ 118 | -p 7051:7051 \ 119 | -e CORE_PEER_ID=vp0 \ 120 | -e CORE_VM_ENDPOINT=http://172.17.0.1:2375 \ 121 | -e CORE_PEER_ADDRESSAUTODETECT=true \ 122 | -e CORE_NOOPS_BLOCK_TIMEOUT=10 \ 123 | yeasy/hyperledger-peer:latest peer node start 124 | ``` 125 | 126 | ### PBFT consensus 127 | PBFT requires at least 4 nodes. 128 | 129 | ```sh 130 | $ git clone https://github.com/yeasy/docker-compose-files 131 | $ cd docker-compose-files/hyperledger 132 | $ docker-compose up 133 | ``` 134 | 135 | More details, please refer to [hyperledger-compose-files](https://github.com/yeasy/docker-compose-files#hyperledger). 136 | 137 | After the cluster starts up, enter into the container 138 | ```sh 139 | $ docker exec -it vp0 bash 140 | ``` 141 | 142 | Inside the container, deploy a chaincode using 143 | 144 | ```sh 145 | $ peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}' 146 | 13:16:35.643 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO 147 | 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 148 | ``` 149 | 150 | Query `a`'s current value, which is 100. 151 | ```sh 152 | $ peer chaincode query -n 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 -c '{"Function": "query", "Args": ["a"]}' 153 | 13:20:07.952 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO 154 | 100 155 | ``` 156 | 157 | Invoke a transaction of 10 from `a` to `b`. 158 | ```sh 159 | $ peer chaincode invoke -n 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 -c '{"Function": "invoke", "Args": ["a", "b", "10"]}' 160 | 13:20:31.028 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO 161 | ec3c675b-a2fe-4429-ab44-7f389e454657 162 | ``` 163 | Query `a` 's value now. 164 | ```sh 165 | $ peer chaincode query -n 5844bc142dcc9e788785e026e22c855957b2c754c912702c58d997dedbc9a042f05d152f6db0fbd7810d95c1b880c210566c9de3093aae0ab76ad2d90e9cfaa5 -c '{"Function": "query", "Args": ["a"]}' 166 | 13:20:35.725 [crypto] main -> INFO 001 Log level recognized 'info', set to INFO 167 | 90 168 | ``` 169 | 170 | More examples, please refer to [hyperledger-compose-files](https://github.com/yeasy/docker-compose-files#hyperledger). 171 | 172 | 173 | If you wanna manually start. 174 | 175 | For root node: 176 | 177 | ```sh 178 | docker run --name=node_vp0 \ 179 | -e CORE_PEER_ID=vp0 \ 180 | -e CORE_PBFT_GENERAL_N=4 \ 181 | --net="host" \ 182 | --restart=unless-stopped \ 183 | -it --rm \ 184 | -p 5500:7050 \ 185 | -p 7051:7051 \ 186 | -v /var/run/docker.sock:/var/run/docker.sock 187 | -e CORE_LOGGING_LEVEL=debug \ 188 | -e CORE_PEER_ADDRESSAUTODETECT=true \ 189 | -e CORE_PEER_NETWORKID=dev \ 190 | -e CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft \ 191 | -e CORE_PBFT_GENERAL_MODE=classic \ 192 | -e CORE_PBFT_GENERAL_TIMEOUT_REQUEST=10s \ 193 | yeasy/hyperledger-peer:latest peer node start 194 | ``` 195 | 196 | for non-root node: 197 | 198 | ```sh 199 | docker run --name=node_vpX \ 200 | -e CORE_PEER_ID=vpX \ 201 | -e CORE_PBFT_GENERAL_N=4 \ 202 | --net="host" \ 203 | --restart=unless-stopped \ 204 | --rm -it \ 205 | -p 7051:7051 \ 206 | --net="hyperledger_cluster_net_pbft" \ 207 | -e CORE_LOGGING_LEVEL=debug \ 208 | -e CORE_PEER_ADDRESSAUTODETECT=true \ 209 | -e CORE_PEER_NETWORKID=dev \ 210 | -e CORE_PEER_VALIDATOR_CONSENSUS_PLUGIN=pbft \ 211 | -e CORE_PBFT_GENERAL_MODE=classic \ 212 | -e CORE_PBFT_GENERAL_TIMEOUT_REQUEST=10s \ 213 | -e CORE_PEER_DISCOVERY_ROOTNODE=vp0:7051 \ 214 | yeasy/hyperledger-peer:latest peer node start 215 | ``` 216 | 217 | 218 | 219 | # Which image is based on? 220 | The image is built based on [hyperledger](https://hub.docker.com/r/yeasy/hyperledger) base image. 221 | 222 | # What has been changed? 223 | ## install dependencies 224 | Install required libsnappy-dev, zlib1g-dev, libbz2-dev. 225 | 226 | ## install rocksdb 227 | Install required rocksdb 4.1. 228 | 229 | ## install hyperledger 230 | Install hyperledger and build the peer 231 | 232 | # Supported Docker versions 233 | 234 | This image is officially supported on Docker version 1.7.0. 235 | 236 | Support for older versions (down to 1.0) is provided on a best-effort basis. 237 | 238 | # Known Issues 239 | * N/A. 240 | 241 | # User Feedback 242 | ## Documentation 243 | Be sure to familiarize yourself with the [repository's `README.md`](https://github.com/yeasy/docker-hyperledger-peer/blob/master/README.md) file before attempting a pull request. 244 | 245 | ## Issues 246 | If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/yeasy/docker-hyperledger-peer/issues). 247 | 248 | You can also reach many of the official image maintainers via the email. 249 | 250 | ## Contributing 251 | 252 | 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. 253 | 254 | Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/yeasy/docker-hyperledger-peer/issues), 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. 255 | --------------------------------------------------------------------------------