我有这样的docker-compose.yml:
version: '2'
networks:
basic:
services:
ca.example.com:
image: hyperledger/fabric-ca
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca.example.com
- FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
# change the keyfile everytime the generate.sh is used
- FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/763ce512db70fbfc91ffcd4ad01d074d3a012ae2488a42dbb1a47a9ce8895de8_sk
ports:
- "7054:7054"
command: sh -c 'fabric-ca-server start -b admin:adminpw'
volumes:
- ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config
container_name: ca.example.com
networks:
- basic
orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer
environment:
- FABRIC_LOGGING_SPEC=info
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer
command: orderer
ports:
- 7050:7050
volumes:
- ./config/:/etc/hyperledger/configtx
- ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/:/etc/hyperledger/msp/orderer
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/:/etc/hyperledger/msp/peerOrg1
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/:/etc/hyperledger/msp/peer1rg1
networks:
- basic
peer0.org1.example.com:
container_name: peer0.org1.example.com
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer0.org1.example.com
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_LISTENADDRESS=0.0.0.0:7051
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984
- CORE_PEER_GOSSIP_ENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
# command: peer node start --peer-chaincodedev=true
ports:
- 7051:7051
- 7053:7053
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.example.com
- couchdb
networks:
- basic
couchdb:
container_name: couchdb
image: hyperledger/fabric-couchdb
# Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
# for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode.
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- 5984:5984
networks:
- basic
cli:
container_name: cli
image: hyperledger/fabric-tools
tty: true
environment:
- GOPATH=/opt/gopath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- FABRIC_LOGGING_SPEC=info
- CORE_PEER_ID=cli
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
- CORE_CHAINCODE_KEEPALIVE=10
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run/
- ./../chaincode/:/opt/gopath/src/github.com/
- ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ./config:/opt/gopath/src/github.com/hyperledger/fabric/peer
- ./config:/etc/hyperledger/configtx/
networks:
- basic
#depends_on:
# - orderer.example.com
# - peer0.org1.example.com
# - couchdb
couchdb1:
container_name: couchdb1
image: hyperledger/fabric-couchdb
environment:
- COUCHDB_USER=
- COUCHDB_PASSWORD=
ports:
- "9984:5984"
networks:
- basic
peer1.org1.example.com:
container_name: peer1.org1.example.com
image: hyperledger/fabric-peer
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_PEER_ID=peer1.org1.example.com
- CORE_PEER_ADDRESS=peer1.org1.example.com:8051
- CORE_PEER_LISTENADDRESS=0.0.0.0:8051
- FABRIC_LOGGING_SPEC=info
- CORE_CHAINCODE_LOGGING_LEVEL=info
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/peer/
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=${COMPOSE_PROJECT_NAME}_basic
- CORE_LEDGER_STATE_STATEDATABASE=CouchDB
- CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
- CORE_PEER_GOSSIP_ENDPOINT=peer1.org1.example.com:8051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:8051
#- FABRIC_LOGGING_SPEC=info
# - CORE_PEER_TLS_ENABLED=true
# - CORE_PEER_GOSSIP_USELEADERELECTION=true
# - CORE_PEER_GOSSIP_ORGLEADER=false
# - CORE_PEER_PROFILE_ENABLED=true
# - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
# - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
# - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt
volumes:
- /var/run/:/host/var/run/
- ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/msp/peer
- ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users
- ./config:/etc/hyperledger/configtx
depends_on:
- orderer.example.com
- couchdb1
ports:
- 8051:8051
networks:
- basic
当我启动Fabric时,所有的硬币容器都正确地上升了,但是如果我对单个容器进行日志记录,除了peer1以外,其他所有容器看起来都很好,
2019-07-19 08:05:35.831 UTC [cceventmgmt] HandleChaincodeDeploy -> INFO 03e Channel [mychannel]: Chaincode [Name=traceability, Version=1.0, Hash=[]byte{0xec, 0xe8, 0x2f, 0xd6, 0x66, 0xe8, 0x39, 0x5f, 0x9a, 0xc5, 0x1d, 0x93, 0x7a, 0xed, 0xc6, 0x43, 0xaf, 0xfa, 0xa0, 0xca, 0x4c, 0x99, 0xb4, 0x8b, 0x0, 0x39, 0x2a, 0xdf, 0xfc, 0xea, 0x7e, 0x44}] is not installed hence no need to create chaincode artifacts for endorsement
2019-07-19 08:05:35.850 UTC [kvledger] CommitWithPvtData -> INFO 03f [mychannel] Committed block [1] with 1 transaction(s) in 22ms (state_validation=5ms block_commit=6ms state_commit=8ms)
*2019-07-19 08:05:39.546 UTC [gossip.discovery] func1 -> WARN 040 Could not connect to Endpoint: 127.0.0.1:7051, InternalEndpoint: 127.0.0.1:7051, PKI-ID: <nil>, Metadata: : context deadline exceeded*
2019-07-19 08:05:42.808 UTC [gossip.privdata] StoreBlock -> INFO 041 [mychannel] Received block [2] from buffer
2019-07-19 08:05:42.809 UTC [committer.txvalidator] Validate -> INFO 042 [mychannel] Validated block [2] in 0ms
2019-07-19 08:05:42.835 UTC [kvledger] CommitWithPvtData -> INFO 043 [mychannel] Committed block [2] with 1 transaction(s) in 26ms (state_validation=3ms block_commit=8ms state_commit=13ms)
*2019-07-19 08:06:07.547 UTC [gossip.discovery] func1 -> WARN 044 Could not connect to Endpoint: 127.0.0.1:7051, InternalEndpoint: 127.0.0.1:7051, PKI-ID: <nil>, Metadata: : context deadline exceeded*
有人知道如何解决此问题吗? 我认为这是与docker-compose文件的配置有关的一些问题,但我不知道出了什么问题,我在网络上看到了不同的配置。
这些是我的容器:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d99aec3ed5b0 dev-peer0.org1.example.com-traceability-1.0-76b4798b7a60d0b2659c39b86072164c35face709e8536003ba90ad0d0211f7c "chaincode -peer.add…" 5 minutes ago Up 5 minutes dev-peer0.org1.example.com-traceability-1.0
1f2ec12ac129 hyperledger/fabric-tools "/bin/bash" 6 minutes ago Up 6 minutes cli
deb0d9f11159 hyperledger/fabric-peer "peer node start" 6 minutes ago Up 6 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
fc9b07f9d487 hyperledger/fabric-peer "peer node start" 6 minutes ago Up 6 minutes 0.0.0.0:8051->8051/tcp peer1.org1.example.com
aad71ba93cc1 hyperledger/fabric-orderer "orderer" 6 minutes ago Up 6 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
8f73d314f8ec hyperledger/fabric-ca "sh -c 'fabric-ca-se…" 6 minutes ago Up 6 minutes 0.0.0.0:7054->7054/tcp ca.example.com
89af426d3101 hyperledger/fabric-couchdb "tini -- /docker-ent…" 6 minutes ago Up 6 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb
aff4a66215a1 hyperledger/fabric-couchdb "tini -- /docker-ent…" 6 minutes ago Up 6 minutes 4369/tcp, 9100/tcp, 0.0.0.0:9984->5984/tcp couchdb1
答案 0 :(得分:1)
尝试以下更改并再次启动docker-
peer0.org1.example.com :
- CORE_PEER_GOSSIP_ENDPOINT=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
使用
peer0.org1.example.com :
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:8051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
和中
peer1.org1.example.com :
- CORE_PEER_GOSSIP_ENDPOINT=peer1.org1.example.com:8051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:8051
使用
peer1.org1.example.com :
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
- CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:8051
答案 1 :(得分:0)
我在docker-compose文件中发现了一个小错字。
在 peer1 部分中的,CORE_PEER_GOSSIP_EXTERNALENDPOINT
应该设置为对等方自己的地址,即peer1.org1.example.com:8051
而不是peer0.org1.com:8051
。您可以纠正它是否起作用,如果不能,请发表评论。