随着 Docker 20.10 的推出,Linux 平台应该可以使用 host-gateway(详见this的精彩回答)。因此,应该可以创建一个平台无关的 docker-compose 脚本。(我自己用的是 Debian。)
以下链接提供了帮助我达到目的的一些问题和答案:here, here, 和 here(连同其他答案和评论)。
我正在尝试为运行The Graph创建一个脚本,其中需要在 Docker 容器内运行 ipfs 和 postgres,并连接到 Docker 外部的区块链实例(端口为 8545)。以下是脚本内容:
Docker启动正常,
以下链接提供了帮助我达到目的的一些问题和答案:here, here, 和 here(连同其他答案和评论)。
我正在尝试为运行The Graph创建一个脚本,其中需要在 Docker 容器内运行 ipfs 和 postgres,并连接到 Docker 外部的区块链实例(端口为 8545)。以下是脚本内容:
version: '3'
services:
graph-node:
extra_hosts:
- "host.docker.internal:host-gateway"
image: graphprotocol/graph-node
ports:
- '8000:8000'
- '8001:8001'
- '8020:8020'
- '8030:8030'
- '8040:8040'
depends_on:
- ipfs
- postgres
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'localhost:http://host.docker.internal:8545'
RUST_LOG: info
ipfs:
image: ipfs/go-ipfs:v0.4.23
ports:
- '5001:5001'
volumes:
- ./data/ipfs:/data/ipfs
postgres:
image: postgres
ports:
- '5432:5432'
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
environment:
POSTGRES_USER: graph-node
POSTGRES_PASSWORD: let-me-in
POSTGRES_DB: graph-node
volumes:
- ./data/postgres:/var/lib/postgresql/data
Docker启动正常,
ipfs
、postgres
和graph-node
实例启动正常,但是graph-node
的RPC调用(到区块链)全部失败,错误类似于以下内容:WARN Trying again after eth_getBlockByNumber(0, false) RPC call failed (attempt #18) with result Err(Transport error: Error(Connect, Os { code: 111, kind: ConnectionRefused, message: "Connection refused" }))
我是否错误地使用了extra-hosts
?我能做些什么来使这个脚本在我的Linux机器上工作,也能适用于Mac和Windows用户吗?
谢谢!