kong搭建(这里和官网有点区别,加了postgres密码):
安装教程参考:
https://blog.csdn.net/qism007/article/details/89521454
1.create a docker network
docker network create kong-net
2.安装postgres数据库,并设置账户和信息
进入postgres
docker exec -it kong-database /bin/bash
创建了数据库账户kong,和密码kong ,创建了数据库kong
create user kong with password 'kong';
create database kong owner kong;
创建了数据库账户konga,和密码konga ,创建了数据库konga
create user konga with password 'konga’;
create database konga owner konga
退出postgres 命令: \q
退出docker命令 exit
3.安装kong
prepare your databases,当kong的版本大于0.15时使用bootstrap:
docker run --rm \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PORT=5432" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kong" \
-e "KONG_PG_DATABASE=kong" \
kong:latest kong migrations bootstrap
start kong:
docker run -d --name kong \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kong" \
-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:latest
4.安装konga
拉konga镜像:
docker pull pantsel/konga:latest
查看postgres docker容器的gateway
docker inspect 61ebcbad38d6(容器id) | grep Gateway
init konga:
docker run --rm pantsel/konga:latest -c prepare -a postgres -u postgresql://konga:[email protected]:5432/konga
启动konga:
docker run -d --name konga \
--network=kong-net \
-p 1337:1337 \
-e "DB_ADAPTER=postgres" \
-e "DB_HOST=172.18.0.1" \
-e "DB_PORT=5432" \
-e "DB_USER=konga" \
-e "DB_PASSWORD=konga" \
-e "DB_DATABASE=konga" \
-e "KONGA_HOOK_TIMEOUT=120000" \
-e "NODE_ENV=production" \
pantsel/konga
进入konga管理页面创建账户
admin/admin123