我试图为我的公司成立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
我在哪里出错了?
答案 0 :(得分:0)
请遵循
步骤: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
如果您需要3.7版的docker compose