"kong: docker-compose [postgresql error] failed to retrieve postgresql server_version_num: host or service not provided, or not known" Code Answer

3
version: "3.7"

volumes:
  kong_data: {}

networks:
 kong-net:

services:

  #######################################
  # postgres: the database used by kong
  #######################################
  kong-database:
    image: postgres:9.6
    container_name: kong-postgres
    restart: on-failure
    networks:
      - kong-net
    volumes:
      - kong_data:/var/lib/postgresql/data
    environment:
      postgres_user: kong
      postgres_password: ${kong_pg_password:-kong}
      postgres_db: kong
    ports:
      - "5432:5432"
    healthcheck:
      test: ["cmd", "pg_isready", "-u", "kong"]
      interval: 30s
      timeout: 30s
      retries: 3

  #######################################
  # kong database migration
  #######################################
  kong-migration:
    image: ${kong_docker_tag:-kong:latest}
    command: kong migrations bootstrap
    networks:
      - kong-net
    restart: on-failure
    environment:
      kong_database: postgres
      kong_pg_host: kong-database
      kong_pg_database: kong
      kong_pg_user: kong
      kong_pg_password: ${kong_pg_password:-kong}
    depends_on:
      - kong-database

  #######################################
  # kong: the api gateway
  #######################################
  kong:
    image: ${kong_docker_tag:-kong:latest}
    restart: on-failure
    networks:
      - kong-net
    environment:
      kong_database: postgres
      kong_pg_host: kong-database
      kong_pg_database: kong
      kong_pg_user: kong
      kong_pg_password: ${kong_pg_password:-kong}
      kong_proxy_listen: 0.0.0.0:8000
      kong_proxy_listen_ssl: 0.0.0.0:8443
      kong_admin_listen: 0.0.0.0:8001
    depends_on:
      - kong-database
    healthcheck:
      test: ["cmd", "kong", "health"]
      interval: 10s
      timeout: 10s
      retries: 10
    ports:
      - "8000:8000"
      - "8001:8001"
      - "8443:8443"
      - "8444:8444"

  #######################################
  # konga database prepare
  #######################################
  konga-prepare:
    image: pantsel/konga:latest
    command: "-c prepare -a postgres -u postgresql://kong:${kong_pg_password:-kong}@kong-database:5432/konga"
    networks:
      - kong-net
    restart: on-failure
    depends_on:
      - kong-database

  #######################################
  # konga: kong gui
  #######################################
  konga:
    image: pantsel/konga:latest
    restart: always
    networks:
        - kong-net   
    environment:
      db_adapter: postgres
      db_uri: postgresql://kong:${kong_pg_password:-kong}@kong-database:5432/konga
      node_env: production
    depends_on:
      - kong-database
    ports:
      - "1337:1337"

By aryelultrafuture-e7be78905c7c on January 15 2022
Only authorized users can answer the Search term. Please sign in first, or register a free account.