Install Kong with PostgreSQL in docker

Create docker network

 $ docker network create kong-net

Start database (psql should be 9.6!!)

 $ docker run -d --name kong-database \
               --network=kong-net \
               -p 5432:5432 \
               -e "POSTGRES_USER=kong" \
               -e "POSTGRES_DB=kong" \
               postgres:9.6

Bootstrap data

$ docker run --rm \
     --network=kong-net \
     -e "KONG_DATABASE=postgres" \
     -e "KONG_PG_HOST=kong-database" \
     kong:latest kong migrations bootstrap

Start Kong, donot expose admin port to public! konga will handle it locally. 9000 and 9443 is for grpc.

 $ docker run -d --name kong \
     --network=kong-net \
     -e "KONG_DATABASE=postgres" \
     -e "KONG_PG_HOST=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" \
     -e "KONG_PROXY_LISTEN=0.0.0.0:9000 http2, 0.0.0.0:9443 http2 ssl" \
     -p 80:8000 \
     -p 443:8443 \
     -p 8001:8001 \
     -p 8444:8444 \
     -p 9000:9000 \
     -p 9443:9443 \
     kong:latest

Install Konga with PostgreSQL in docker

Make sure there's not any database named konga in your psql. Use develpment env to create the db. Set KONGA_HOOK_TIMEOUT to more than 60000 to avoid hook break up.

 $ docker run --name konga \
     --network kong-net \
     -e "KONGA_HOOK_TIMEOUT=120000" \
     -e "DB_ADAPTER=postgres" \
     -e "DB_URI=postgresql://kong:@172.18.0.1:5432/konga" \
     -p 1337:1337 \
     pantsel/konga:latest

If you see this

debug: Hook:api_health_checks:process() called
debug: Hook:health_checks:process() called
debug: Hook:start-scheduled-snapshots:process() called
debug: Hook:upstream_health_checks:process() called
debug: Hook:user_events_hook:process() called
debug: Seeding User...
debug: User seed planted
debug: Seeding Kongnode...
debug: Kongnode seed planted
debug: Emailtransport seeds updated
debug: -------------------------------------------------------
debug: :: Thu Dec 05 2019 03:01:53 GMT+0000 (Coordinated Universal Time)
debug: Environment : development
debug: Host        : 0.0.0.0
debug: Port        : 1337
debug: -------------------------------------------------------

All done