Skip to main content

Kong Gateway

Kong Gateway is an open core project that offers many of the traditional API Management features.


Minimal Docker Compose for Kong

version: "3.0"

services:

  kong:
    env_file: .env
    image: kong/kong-gateway:3.0.1.0
    environment:
      - KONG_DATABASE=postgres
      - KONG_PG_HOST=db
      - KONG_PG_DATABASE=kong
      - KONG_PG_USER=postgres
      - KONG_PG_PASSWORD=${POSTGRES_PASSWORD}
      - KONG_ADMIN_LISTEN=0.0.0.0:8001
      - KONG_ADMIN_GUI_URL=http://localhost:8002
    ports:
      - 8000:8000 
      - 8443:8443 
      - 8001:8001 
      - 8444:8444 
      - 8002:8002 
      - 8445:8445 
      - 8003:8003 
      - 8004:8004 

  db:
    env_file: .env
    image: postgres
    restart: always
    volumes:
      - ./postgres:/var/lib/postgresql/data 
    ports:
      - 5432:5432
      
  adminer:
    env_file: .env
    image: adminer
    restart: always
    ports:
      - 8080:8080

And accompanying .env file:

POSTGRES_PASSWORD=example
KONG_PASSWORD="supersecret123"

Docker Compose Installation

The official documentation for the project provides a walkthrough for docker installation here

Seed the Database

docker-compose run kong kong migrations bootstrap

 

Kong Config and  Environment Variables

Kong normally reads a config file called kong.conf - an overview of valid configuration settings/directives can be found here

The docker image can read these variables from the environment. Simply copy the name of the thing, upercase it and prefix with KONG_ e.g. prefix becomes KONG_PREFIX.