1. 创建kong-net网络
docker network create kong-net
2. 安装postgres数据库
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
postgres:9.6
3. 初始化kong数据库
docker run --rm --network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
kong:1.5 kong migrations up
4. 启动kong网关
docker run -d --name kong \
--network=kong-net \
--restart=always \
-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:1.5
5. kong 的UI 管理页面部署
docker run --it -d -p 1337:1337 \
--network kong-net \
--restart=always \
-e "TOKEN_SECRET=6666666" \
-e "DB_ADAPTER=postgres" \
-e "DB_HOST=192.168.138.128" \
-e "DB_PORT=5432" \
-e "DB_USER=kong" \
-e "DB_PASSWORD=*****" \
-e "DB_DATABASE=kong_database" \
-e "NODE_ENV=production" \
--name konga \
pantsel/konga:0.14.3