在docker-compose中运行Konga时出现身份验证错误

时间:2020-02-27 13:57:56

标签: docker-compose kong konga

我有一个启动kong和konga服务的docker-compose文件。 Kong正确启动,但是konga失败并显示以下错误:

debug: Preparing database...
Using postgres DB Adapter.
Failed to connect to DB { error: password authentication failed for user "kong"
    at Connection.parseE (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/app/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: 'error',
length: 100,
severity: 'FATAL',
code: '28P01',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'auth.c',
line: '333',
routine: 'auth_failed' }

在我的docker-compose中,Kong服务来自其github页面,并且运行良好。.我相信,问题出在Konga。 Konga服务如下:

version: '2.1' 

volumes:
  kong_data: {}

services:
  db:
    image: postgres:latest
    environment:
      POSTGRES_DB: ${KONG_PG_DATABASE:-kong}
      POSTGRES_PASSWORD: ${KONG_PG_PASSWORD:-kong}
      POSTGRES_USER: ${KONG_PG_USER:-kong}
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "${KONG_PG_USER:-kong}"]
      interval: 30s
      timeout: 30s
      retries: 3
    restart: on-failure
    stdin_open: true
    tty: true
    networks:
      - kong_net
    volumes:
      - kong_data:/var/lib/postgresql/data

   konga-prepare:
     image: pantsel/konga:latest
     command: “-c prepare -a postgres -u postgresql://kong@db:5432/konga_db”
     networks:
       - kong_net
     restart: on-failure
     links:
       - db
     depends_on:
       - db

   konga:
     image: pantsel/konga:latest
     restart: always
     networks:
         - kong_net
     environment:
       DB_ADAPTER: postgres
       DB_HOST: db
       DB_PORT: 5432
       DB_USER: konga
       DB_PASSWORD: 
       TOKEN_SECRET: km1GUr4RkcQD7DewhJPNXrCuZwcKmqjb
       DB_DATABASE: konga_db
       NODE_ENV: production
     depends_on:
       - db
     ports:
       - "1337:1337"

如何解决身份验证错误?

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,我通过向konga-prepare命令添加密码来解决了这个问题:

docker run --rm --network=kong-net pantsel/konga:latest -c prepare -a postgres -u postgresql://kong:kong@kong-database:5432/konga_database