https://docs.konghq.com/gateway/latest/install/docker/
# 创建docker网络
docker network create kong-net
# 启动postgres数据库
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
-e "POSTGRES_PASSWORD=kongpass" \
postgres:13
# 初始化数据库(若报错,改用一行)
docker run --rm --network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kongpass" \
-e "KONG_PASSWORD=test" \
kong/kong-gateway:3.8.1.0 kong migrations bootstrap
# 启动kong容器
docker run -d --name kong-gateway \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kongpass" \
-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" \
-e "KONG_ADMIN_GUI_URL=http://localhost:8002" \
-e KONG_LICENSE_DATA \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
-p 8002:8002 \
-p 8445:8445 \
-p 8003:8003 \
-p 8004:8004 \
kong/kong-gateway:3.8.1.0
#接口API
curl -i -X GET --url http://localhost:8001/services
#管理UI
http://localhost:8002
#跳转端口,需配置url后才能生效
http://localhost:8000/
# 初始化kong数据库 (若报错,合在一行执行)
docker run --rm --network=lnet0 \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=192.168.1.100" \
-e "KONG_PG_PORT=9432" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kongpass" \
rss.jobpi.cn/kong:3.8.0 kong migrations bootstrap
...
参数: https://docs.konghq.com/gateway/3.8.x/reference/configuration/#postgres-settings