【问题标题】:Docker Compose on Crunchy Postgres and Hasura Graphql Engine - Database URL settingsDocker Compose 在 Crunchy Postgres 和 Hasura Graphql 引擎上 - 数据库 URL 设置
【发布时间】:2019-07-05 17:53:51
【问题描述】:

如果问题不清楚或没有足够的信息,请告诉我,因为我已尽力根据我的理解提出我的问题...

我正在尝试使用 Hasura GraphQL 引擎配置 Crunchy Postgres 图像,我尝试按照文档的建议更改主机名,但它根本没有连接到我的 Crunchy Postgres 图像。

文档链接:

https://docs.hasura.io/1.0/graphql/manual/deployment/docker/index.html

https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-compose/docker-compose.yaml

https://hub.docker.com/r/crunchydata/crunchy-postgres/

我的 Docker-Compose 文件:

version: '3.5'

services:
  unipgdb:
    image: crunchydata/crunchy-postgres:centos7-11.1-2.3.0
    restart: always
    ports:
      - "5432:5432"
    env_file:
      - ./config/postgres/cpg-env.list
    volumes:
      - unipgdata_volume:/var/lib/postgresql/data
    networks:
      - unicausalapi

  graphql-engine:
    image: hasura/graphql-engine:v1.0.0-alpha37
    ports:
      - "8080:80"
    depends_on:
      - "unipgdb"
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://user:password@postgres:5432/unipgdb
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
      ## uncomment next line to set an access key
      # HASURA_GRAPHQL_ACCESS_KEY: mysecretaccesskey
    networks:
      - unicausalapi

  # For Hasura engine
  caddyhasura:
    build:
      context: .
      dockerfile: caddyhasura-Dockerfile
    depends_on:
      - graphql-engine
    networks:
      - unicausalapi
      - unicausalpublic
      - unicausalnetwork

volumes:
  static_volume:  # <-- declare the static volume
  media_volume:  # <-- declare the media volume
  unipgdata_volume:
      external: true

networks:
   unicausalpublic:
      external: true
   unicausalnetwork:
      external: true
   unicausalapi:
      external: true

在 caddyhasura 服务的 Caddyfile 中,它只是容器 graphql-engine 上的反向代理,所以它应该不会影响我的问题。

我认为我使用主机名错误地配置了 HASURA_GRAPHQL_DATABASE_URL,因为我不确定使用 crunchy-postgres:centos7 图像应该放什么。

我在 Docker 日志中收到此错误

如何配置它以使用这些图像处理我的 docker-compose 文件?

HASURA_GRAPHQL_DATABASE_URL: postgres://user:password@postgres:5432/unipgdb

有什么想法可以尝试解决我的问题吗?提前致谢。

【问题讨论】:

    标签: postgresql docker docker-compose hasura


    【解决方案1】:

    由于 Crunchy Postgres 容器的名称是 unipgdb,因此容器的主机名将相同。而不是postgres 作为主机名,你应该使用它。

    所以,你的数据库 url 会变成

    HASURA_GRAPHQL_DATABASE_URL: postgres://user:password@unipgdb:5432/unipgdb

    如果您的用户名或密码包含特殊字符(如 $、#、@ 等),请确保您对 URL 进行编码并在 URL 中使用它们。参考:https://www.degraeve.com/reference/urlencoding.php

    例如如果密码为secretPassW$or#,则应输入secretPassW%24or%23

    【讨论】:

      猜你喜欢
      • 2019-03-14
      • 2021-01-30
      • 1970-01-01
      • 1970-01-01
      • 2018-04-06
      • 2021-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多