创建CouchDB的多个docker实例时出错

创建CouchDB的多个docker实例时出错,docker,couchdb,hyperledger-fabric,Docker,Couchdb,Hyperledger Fabric,我一直在尝试为单个主机(node1)中的两个对等机创建两个docker CouchDB实例。但是,只有一个对等点和一个couchdb实例启动,而另一个在“n”秒内退出。这是我的docker-compose-node1.yml文件的外观: peer2.example: container_name: peer2.example extends: file: docker-compose-peer.yml service: peer-base environment:

我一直在尝试为单个主机(node1)中的两个对等机创建两个docker CouchDB实例。但是,只有一个对等点和一个couchdb实例启动,而另一个在“n”秒内退出。这是我的docker-compose-node1.yml文件的外观:

peer2.example:
  container_name: peer2.example
  extends:
    file: docker-compose-peer.yml
    service: peer-base
  environment:
    - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb_peer2:5984
    - CORE_PEER_ID=peer2.example
    - CORE_PEER_ADDRESS=peer2.example:7051
    - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
    - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
  ports:
    - 7051:7051
    - 7053:7053
  volumes:
    - ./crypto-config/peerOrganizations/example/peers/peer2.example:/etc/hyperledger/peers
    - ./crypto-config/peerOrganizations/example/peers/peer2.example/msp:/etc/hyperledger/peers/msp
    - ./crypto-config/peerOrganizations/example/peers/peer2.example/tls:/etc/hyperledger/peers/tls
    - ./crypto-config/peerOrganizations/example/users:/etc/hyperledger/msp/users
  depends_on:
    - couchdb_peer2 

couchdb_peer2:
  container_name: couchdb_peer2
  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=
    #DB_URL: http://localhost:5984/member_db
  ports:
    - "5984:5984"
  network_mode: "host"

peer4.example:
  container_name: peer4.example
  extends:
    file: docker-compose-peer.yml
    service: peer-base
  environment:
    - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb_peer4:5984
    - CORE_PEER_ID=peer4
    - CORE_PEER_ADDRESS=peer4.example:7050
    - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
    - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
  ports:
    - 8051:7051
    - 8053:7053
  volumes:
    - ./crypto-config/peerOrganizations/example/peers/peer4.example:/etc/hyperledger/peers
    - ./crypto-config/peerOrganizations/example/peers/peer4.example/msp:/etc/hyperledger/peers/msp
    - ./crypto-config/peerOrganizations/example/peers/peer4.example/tls:/etc/hyperledger/peers/tls
    - ./crypto-config/peerOrganizations/example/users:/etc/hyperledger/msp/users
depends_on:
    - couchdb_peer4

couchdb_peer4:
  container_name: couchdb_peer4
  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=
    #DB_URL: http://localhost:5984/member_db
  ports:
    - "6984:5984"
  network_mode: "host"
这就是错误:

2018-02-15 19:36:11.359 UTC [couchdb] CreateSystemDatabasesIfNotExist -> ERRO 024 Error during CouchDB CreateDatabaseIfNotExist() for system dbName: _users  error: Couch DB Error:file_exists,  Status Code:412,  Reason:The database could not be created, the file already exists.
2018-02-15 19:36:11.359 UTC [couchdb] VerifyCouchConfig -> ERRO 025 Unable to connect to CouchDB,  error: Couch DB Error:file_exists,  Status Code:412,  Reason:The database could not be created, the file already exists.   Check the admin username and password.
我在/etc/hosts文件docker-compose-peer.yml和crypto-config.yaml中做了必要的更改

这是我用来启动容器的命令:

docker-compose -f docker-compose-node1.yml up -d peer4.example peer2.example
这是docker ps命令显示的内容(删除了容器ID列):


我错过了什么。如果您需要我发布docker-compose-peer.yml文件,也请告诉我。谢谢

您使用network_mode=host作为CouchDB容器的原因是什么?我会从你的compose文件中删除它,否则我相信会发生这样的情况:对等方最终连接到同一个容器实例。我尝试将其更改为“bridge”,但这也没有帮助。现在有两个couchdb实例保持运行状态,但两个对等方都退出。这就是它现在抛出的错误:恐慌:实例化分类账提供程序时出错:无法连接到CouchDB,请检查主机名和端口:Get:dial tcp:lookup CouchDB_peer2 on 10.a.b.c:53:read udp 172.d.e.f:51223->10.a.b.c:53:i/o超时。我也不确定它从哪里获取10.a.b.c IP。查看了local.ini文件,但没有任何硬编码IP。
IMAGE                        COMMAND                  CREATED             STATUS                           PORTS               NAMES
hyperledger/fabric-peer      "peer node start"        3 minutes ago       Up 3 minutes                            peer2.example
hyperledger/fabric-couchdb   "tini -- /docker-e..."   3 minutes ago       Up 3 minutes                            couchdb_peer4