在 Docker-Compose 中设置 Chainlink 密钥库密码

Setting Chainlink Keystore Password in Docker-Compose

我正在尝试使用 docker-compose 启动一个 chainlink 节点,但 运行 遇到了这个错误:

error authenticating keystore: No password provided

我没有看到设置此密码的环境变量。本教程 (https://docs.chain.link/docs/running-a-chainlink-node/#set-the-remote-database_url-config) 使用 docker 并直接执行到容器中以根据提示进行设置。有人知道在启动容器时不需要手动输入的解决方案吗?

这是我的 docker-compose.yml

version: '2.1'

x-logging:
  &default-logging
  options:
    max-file: '1'
    compress: 'false'
  driver: local

networks:
  monitor-net:
    driver: bridge

volumes:
    postgres_data: {}

services:
  chainlink-node:
    image: smartcontract/chainlink:0.10.8
    container_name: chainlink
    depends_on:
      - postgres
    environment:
      LOG_LEVEL: ${LOG_LEVEL}
      ETH_CHAIN_ID: ${ETH_CHAIN_ID}
      ETH_URL: ${ETH_URL}
      ETH_HTTP_URL: ${ETH_HTTP_URL}
      DATABASE_URL: postgresql://${DB_USER}:${DB_PW}@postgres:5432/${CHAINLINK_DB_NAME}
      MIN_OUTGOING_CONFIRMATIONS: "${MIN_OUTGOING_CONFIRMATIONS}"
      LINK_CONTRACT_ADDRESS: "${LINK_CONTRACT_ADDRESS}"
      CHAINLINK_TLS_PORT: "${CHAINLINK_TLS_PORT}"
      SECURE_COOKIES: "${SECURE_COOKIES}"
      GAS_UPDATER_ENABLED: "${GAS_UPDATER_ENABLED}"
      ALLOW_ORIGINS: "${ALLOW_ORIGINS}"
    expose:
      - 6688
    ports:
      - "6688:6688"
networks:
      - monitor-net
    restart: unless-stopped
    logging: *default-logging
  postgres:
    image: postgres:13.1
    container_name: postgres
    command: ["postgres", "-c", "max_connections=1000", "-c", "shared_buffers=256MB", "-c", "shared_preload_libraries=pg_stat_statements"]
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${DB_USER:-username}
      POSTGRES_PASSWORD: ${DB_PW:-password}
      POSTGRES_DB: ${CHAINLINK_DB_NAME:-chainlink-db}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - monitor-net
    expose:
 - 5432
    logging: *default-logging

还有我的 .env 文件

DB_USER=<username>
DB_PW=<password>
CHAINLINK_DB_NAME=chainlink-db
LOG_LEVEL=debug
ETH_CHAIN_ID=4
ETH_URL=wss://rinkeby.infura.io/ws/v3/<>
ETH_HTTP_URL=https://rinkeby.infura.io/v3/<>
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0x01BE23585060835E02B77ef475b0Cc51aA1e0709
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
GAS_UPDATER_ENABLED=true
ALLOW_ORIGINS=*\" > ~/chainlink-rinkeby/.env

编辑:

经过一番折腾后,我找到了 docker-compose.yml 文件的配置,它允许 chainlink 容器以稳定状态启动。

services:
  chainlink-node:
    image: smartcontract/chainlink:0.10.8
    container_name: chainlink
    command: ["local", "n", "-p", "/chainlink/password", "-a", "/chainlink/api"]
    volumes:
      - ./passwords:/chainlink

chainlink 节点需要不同的凭证来初始化。这些是创建和访问网络相关钱包(primaryemergency)所需的 key-store password 和可以访问图形用户界面的 API-credentails Chainlink 节点的 (GUI)。

这些凭证在初始化期间被查询,并在 Chainlink 节点首次启动时手动输入。如果 chainlink 节点在 detached mode-d 标志)或作为 docker-compose 文件启动,则这些凭据必须作为卷安装并添加为 arguments/commands.

使用 Docker-compose,您可以通过不同的方式来集成这些凭据以启用初始化。我会推荐以下步骤:

  1. 创建文件keystore password: 请确保您至少有 3 个大写字母
echo "my_wallet_password" > ~/.chainlink-rinkeby/.password
  1. 创建 API 凭据:
echo "user@example.com" > ~/.chainlink-rinkeby/.api
echo "password" >> ~/.chainlink-rinkeby/.api
  1. 调整docker-compose.yml:

您现在需要通过将 .chainlink-rinkeby 添加为 volume 并将这些凭据设置为参数 (command:)

chainlink-node:
    image: smartcontract/chainlink:0.10.8
    container_name: chainlink
    command: ["-p /chainlink/.password","-a /chainlink/.api"]
    volumes:
      - ~/.chainlink-rinkeby:/chainlink
    depends_on:
      - postgres
    environment:
      LOG_LEVEL: ${LOG_LEVEL}
      ETH_CHAIN_ID: ${ETH_CHAIN_ID}
      ETH_URL: ${ETH_URL}
      ETH_HTTP_URL: ${ETH_HTTP_URL}
      DATABASE_URL: postgresql://${DB_USER}:${DB_PW}@postgres:5432/${CHAINLINK_DB_NAME}
      MIN_OUTGOING_CONFIRMATIONS: "${MIN_OUTGOING_CONFIRMATIONS}"
      LINK_CONTRACT_ADDRESS: "${LINK_CONTRACT_ADDRESS}"
      CHAINLINK_TLS_PORT: "${CHAINLINK_TLS_PORT}"
      SECURE_COOKIES: "${SECURE_COOKIES}"
      GAS_UPDATER_ENABLED: "${GAS_UPDATER_ENABLED}"
      ALLOW_ORIGINS: "${ALLOW_ORIGINS}"
    expose:
      - 6688
    ports:
      - "6688:6688"

此外,您还可以在此处找到与此主题相关的官方 Chainlink 文档:https://docs.chain.link/docs/miscellaneous/