HyperLedger Fabric 1.0的Alpha版本已經(jīng)于2017年3月中旬正式發(fā)布枕稀,其官方Docker鏡像版本也已經(jīng)發(fā)出。具體地址為[1]项玛。
這樣剩膘,我們就可以通過拉取鏡像的方式,從官網(wǎng)直接拉取鏡像進行部署绑青。
我們可能用到的鏡像包括:
- hyperledger/fabric-orderer:x86_64-1.0.0-alpha
- hyperledger/fabric-peer:x86_64-1.0.0-alpha
- hyperledger/fabric-javaenv:x86_64-1.0.0-alpha
- hyperledger/fabric-ccenv:x86_64-1.0.0-alpha
- hyperledger/fabric-couchdb:x86_64-1.0.0-alpha
- hyperledger/fabric-zookeeper:x86_64-1.0.0-alpha
- hyperledger/fabric-kafka:x86_64-1.0.0-alpha
- hyperledger/fabric-ca:x86_64-1.0.0-alpha
1. 鏡像拉取#
對于每一個鏡像诬像,我們可以通過執(zhí)行下面的指令進行拉取。
docker pull <image name>
像這種一下拉取很多鏡像的情況闸婴,我們也可以寫成一個腳本fabric-pull.sh
:
docker pull hyperledger/fabric-orderer:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-peer:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-javaenv:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-ccenv:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-couchdb:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-kafka:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-ca:x86_64-1.0.0-alpha
由于網(wǎng)絡(luò)不穩(wěn)定的原因坏挠,可能在某個鏡像拉取過程中會出現(xiàn)連接失敗的情況。多執(zhí)行幾次腳本邪乍,問題可能就會解決降狠。
拉取完成后,可以通過docker images
命令查看拉取結(jié)果:
可以看到所有的鏡像TAG都是x86_64-1.0.0-alpha庇楞,至此榜配,鏡像拉取成功。
2. 編寫Docker-Compose文件#
接下來吕晌,我們利用docker-compose來部署網(wǎng)絡(luò)蛋褥。這里我參照了楊博士的最小網(wǎng)絡(luò)啟動docker-compose文件[2]。
并相應(yīng)針對當前版本修改了其中的一些內(nèi)容睛驳,主要是將ca的啟動部分做了一下修改烙心,參考官方ca說明文檔中的docker啟動方法[3]。
docker-compose.yaml
# This compose file will start a Hyperledger Fabric 1.0 MVE, including
# * ca
# * orderer
# * peer
# * sdk for testing
version: '2.0'
services:
ca:
image: hyperledger/fabric-ca:x86_64-1.0.0-alpha
container_name: fabric-ca-server
ports:
- "7054:7054"
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
volumes:
- "./fabric-ca-server:/etc/hyperledger/fabric-ca-server"
command: sh -c 'fabric-ca-server start -b admin:adminpw'
orderer:
image: hyperledger/fabric-orderer:x86_64-1.0.0-alpha
container_name: fabric-orderer
hostname: orderer
environment:
- ORDERER_GENERAL_LEDGERTYPE=ram
- ORDERER_GENERAL_BATCHTIMEOUT=10s
- ORDERER_GENERAL_MAXMESSAGECOUNT=10
- ORDERER_GENERAL_MAXWINDOWSIZE=1000
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_LISTENPORT=7050
- ORDERER_RAMLEDGER_HISTORY_SIZE=100
- CONFIGTX_ORDERER_ORDERERTYPE=solo
ports:
- "7050:7050"
command: orderer
peer0:
extends:
file: peer.yml
service: peer
container_name: fabric-peer0
hostname: peer0
environment:
- CORE_PEER_ID=peer0
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
links:
- ca
- orderer
ports:
- 7051:7051
depends_on:
- ca
- orderer
peer.yaml
# Depends on the hyperledger/fabric-peer image.
version: '2'
services:
peer:
image: hyperledger/fabric-peer:x86_64-1.0.0-alpha
environment:
#- CORE_PEER_ID=peer0
- CORE_PEER_ADDRESSAUTODETECT=true
- CORE_LOGGING_LEVEL=INFO
#- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=hyperledger_fabric # uncomment this to use specific network
#- CORE_PEER_NETWORKID=dev
- CORE_NEXT=true
- CORE_PEER_ENDORSER_ENABLED=true
- CORE_PEER_COMMITTER_ENABLED=true
- CORE_PEER_PROFILE_ENABLED=false
- CORE_PEER_GOSSIP_ORGLEADER=true
- CORE_PEER_GOSSIP_IGNORESECURITY=true
#- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050
expose:
- "7050" # Rest
- "7051" # Grpc
- "7052" # Peer CLI
- "7053" # Peer Event
- "7054" # eCAP
- "7055" # eCAA
- "7056" # tCAP
- "7057" # eCAA
- "7058" # tlsCAP
- "7059" # tlsCAA
volumes: # docker.sock is mapped as the default CORE_VM_ENDPOINT
- /var/run/docker.sock:/var/run/docker.sock
#volumes:
# - /var/run/:/host/var/run/
command: peer node start
3. 執(zhí)行部署#
最后乏沸,我們將這兩個yaml文件放在一起淫茵,執(zhí)行:
docker-compose up
當然,也可以在后臺啟動屎蜓,不在前端顯示log:
docker-compose up -d
然后通過docker ps
查看容器啟動狀態(tài):
至此痘昌,HyperLedger Fabric 1.0 Alpha版單節(jié)點部署成功。
References
[1] https://hub.docker.com/u/hyperledger/
[2] https://github.com/yeasy/docker-compose-files
[3] https://github.com/hyperledger/fabric/blob/master/docs/source/Setup/ca-setup.rst