【问题标题】:chainlink docker to postgres docker将 docker 链接到 postgres docker
【发布时间】:2022-11-05 09:34:05
【问题描述】:

我正在尝试将chainlink连接到postgres db,同样我将它们都作为docker镜像运行。

我将 postgres docker 启动为:

$ docker run --name some-postgres -e POSTGRES_PASSWORD=secret -p 5432:5432 -d postgres

这将成功启动 postgres。

但是,如果我尝试使用以下 .env 连接链环(根据chainlink doc) 文件

ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=5
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
ALLOW_ORIGINS=*
ETH_URL=wss://eth-goerli.g.alchemy.com/v2/<API KEY>
DATABASE_URL=postgresql://some-postgres:secret@postgres:5432/postgres?sslmode=disable

我正在尝试使用密码作为“secret”连接到“some-postgres”实例,但它仍然抛出错误

Cannot boot Chainlink: opening db: failed to open db: failed to connect to `host=postgres user=some-postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.1.1:53: read udp 172.17.0.3:47766->192.168.1.1:53: i/o timeout)                                  err=Cannot boot Chainlink: opening db: failed to open db: failed to connect to `host=postgres user=some-postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.1.1:53: read udp 172.17.0.3:47766->192.168.1.1:53: i/o timeout) errVerbose=opening db: failed to open db: failed to connect to `host=postgres user=some-postgres database=postgres`: hostname resolving error (lookup postgres on 192.168.1.1:53: read udp 172.17.0.3:47766->192.168.1.1:53: i/o timeout)
Cannot boot Chainlink

我不知道为什么它没有将chainlink docker连接到postgres docker。

【问题讨论】:

    标签: postgresql docker chainlink


    【解决方案1】:

    我认为您的 DATABASE_URL env var 组成不正确?

    根据您引用的 Chainlink Docs,数据库连接字符串应遵循以下格式: "DATABASE_URL=postgresql://$USERNAME:$PASSWORD@$SERVER:$PORT/$DATABASE"

    我认为您已将user-postgres 作为您的用户名,而实际上它可能是服务器名称?

    Postgres 数据库用户名和密码可以直接在您的 DATABASE_URL 连接字符串中设置,然后您可能不需要在 docker run 命令中传递它。

    但首先要确保你知道用户名和密码(参考these docs)和 Postgres docker 文档。

    然后使用文档中提供的格式仔细填写您的连接字符串。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-17
      • 1970-01-01
      • 2020-02-19
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多