gpt4 book ai didi

docker - Kong:缺少用于连接的数据库

转载 作者:行者123 更新时间:2023-12-02 19:47:01 27 4
gpt4 key购买 nike

我试图为我的公司成立Kong,所以我遵循Kong文档的指示。
首先我运行以下命令:

docker network create kong-net
然后此命令:
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
-e "POSTGRES_PASSWORD=kong" \
postgres:9.6
根据文档,下一步是使用此命令运行迁移
docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" kong:latest kong migrations up
但它一直给我这个错误
Error: missing database for connect
完整日志
Error:
/usr/local/share/lua/5.1/pgmoon/init.lua:547: missing database for connect
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/pgmoon/init.lua:547: in function 'send_startup_message'
/usr/local/share/lua/5.1/pgmoon/init.lua:207: in function 'connect'
.../share/lua/5.1/kong/db/strategies/postgres/connector.lua:202: in function 'connect'
.../share/lua/5.1/kong/db/strategies/postgres/connector.lua:489: in function 'query'
.../share/lua/5.1/kong/db/strategies/postgres/connector.lua:270: in function 'init'
/usr/local/share/lua/5.1/kong/db/init.lua:138: in function 'init_connector'
/usr/local/share/lua/5.1/kong/cmd/migrations.lua:95: in function 'cmd_exec'
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
/usr/local/bin/kong:9: in function 'file_gen'
init_worker_by_lua:48: in function <init_worker_by_lua:46>
[C]: in function 'xpcall'
init_worker_by_lua:55: in function <init_worker_by_lua:53>
2020/07/23 03:38:40 [verbose] no config file found at /etc/kong/kong.conf
2020/07/23 03:38:40 [verbose] no config file found at /etc/kong.conf
2020/07/23 03:38:40 [verbose] no config file, skip loading
2020/07/23 03:38:40 [verbose] prefix in use: /usr/local/kong
我哪里做错了 ?

最佳答案

请遵循这个
步骤1

docker run -d --name kong-database \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
postgres:9.6
第2步
docker run --rm \
--link kong-database:kong-database \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
kong kong migrations up
步骤:3
docker run -d --name kong \
--link kong-database:kong-database \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
kong
如果您没有任何问题,也可以使用docker-compose
更新了
version: "2"

services:
kong-database:
image: postgres:9.6
container_name: kong-database
ports:
- 5432:5432
environment:
POSTGRES_DB: kong
POSTGRES_USER: kong
POSTGRES_PASSWORD: kong

kong:
image: kong:latest
command: "kong migrations bootstrap"
restart: always
links:
- kong-database:kong-database
ports:
- 8000:8000
- 8443:8443
- 8001:8001
- 7946:7946
- 7946:7946/udp
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_PASSWORD=kong
- KONG_PG_USER=kong

如果您需要Docker的3.7版撰写
https://stackoverflow.com/a/60511959/5525824

关于docker - Kong:缺少用于连接的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63046553/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com