【问题标题】:connect hasura to existing postgresql将 hasura 连接到现有的 postgresql
【发布时间】:2021-03-25 04:30:21
【问题描述】:
  • 在 WSL2 中运行的 Docker 桌面 (windows10)
  • 在 WSL2 中运行的 postgresql
  • pgadmin 在 windows10 中运行

我可以使用默认设置将 pgadmin(本地机器)连接到 postgresql(本地机器 WSL2) (本地主机:5432)

postgres.conf

listen_addresses = '*'
port = 5432

当我创建一个 docker 容器时,它不会连接到我的本地 postgresql。

WSL2中使用的cmd

docker run -d --net=host \
       -e HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:password@localhost:5432/mydb \
       -e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
       -e HASURA_GRAPHQL_DEV_MODE=true \
       hasura/graphql-engine:v1.3.3

错误

"could not connect to server: Connection refused\n\tIs the server running on host \"localhost\" (127.0.0.1) and accepting\n\tTCP/IP connections on port 5432?\n","path":"$","error":"connection error","code":"postgres-error"}

我错过了什么?

【问题讨论】:

    标签: postgresql docker hasura


    【解决方案1】:

    原来我不得不使用这个:

    docker run -d -p 8080:8080 
    -e HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:password@host.docker.internal:5432/mydb \      
    -e HASURA_GRAPHQL_ENABLE_CONSOLE=true  \
    -e HASURA_GRAPHQL_DEV_MODE=true        \
    hasura/graphql-engine:v1.3.3
    

    我认为“host.docker.internal”仅适用于 Mac。似乎也可以与 Docker Desktop Windows10(WSL2) 一起使用。

    【讨论】:

    • 恭喜!我只是想写信告诉你,docker 内部的 hasura 对主机一无所知。
    猜你喜欢
    • 2021-11-13
    • 2020-03-24
    • 1970-01-01
    • 1970-01-01
    • 2021-04-16
    • 2019-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多