无法连接到 Postgres 数据库 Postgres 需要连接到特定数据库,尝试了以下数据库:

Failed to connect to Postgres database Postgres requires connecting to a specific database, the following databases were tried:

当我尝试连接我的 fabric-ca 以将 postgres 用作数据库时出现此错误。

Using postgres database, connecting to database...
    2019/10/22 09:21:16 [DEBUG] Database Name: fabriccaserver
    2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=fabriccaserver sslmode=disable
    2019/10/22 09:21:16 [WARNING] Failed to connect to database 'fabriccaserver'
    2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=postgres sslmode=disable
    2019/10/22 09:21:16 [WARNING] Failed to connect to database 'postgres'
    2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=template1 sslmode=disable
    2019/10/22 09:21:16 [WARNING] Failed to connect to database 'template1'
    2019/10/22 09:21:16 [ERROR] Error occurred initializing database: Failed to connect to Postgres database. Postgres requires connecting to a specific database, the following databases were tried: [fabriccaserver postgres template1]. Please create one of these database before continuing

我通过将 container_name 放入主机中解决了这个错误,即。

db:
  db:
  type: postgres
  datasource: host=db-postgres port=5432 user=postgres password=caDbPass12345 dbname=fabriccaserver sslmode=disable  
  tls:
      enabled: false
      certfiles:
      client:
        certfile:
        keyfile:

之前,我进入本地主机并尝试使用 127.0.0.1,之后我在 docker-compose.yaml 中看到我的 postgres 服务在不同的网络和 ica 下。org1.example.com 在我修复的不同网络下,在杀死并删除所有 docker 进程后还必须执行 docker 网络修剪。