Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
example docker-compose.yml for kong, postgres and konga
version: "3"
networks:
kong-net:
driver: bridge
services:
#######################################
# Postgres: The database used by Kong
#######################################
kong-database:
image: postgres:9.6
restart: always
networks:
- kong-net
environment:
POSTGRES_USER: kong
POSTGRES_DB: kong
ports:
- "5432:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "kong"]
interval: 5s
timeout: 5s
retries: 5
#######################################
# Kong database migration
#######################################
kong-migration:
image: kong:latest
command: "kong migrations up"
networks:
- kong-net
restart: on-failure
environment:
KONG_PG_HOST: kong-database
links:
- kong-database
depends_on:
- kong-database
#######################################
# Kong: The API Gateway
#######################################
kong:
image: kong:latest
restart: always
networks:
- kong-net
environment:
KONG_PG_HOST: kong-database
KONG_PROXY_LISTEN: 0.0.0.0:8000
KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443
KONG_ADMIN_LISTEN: 0.0.0.0:8001
depends_on:
- kong-migration
- kong-database
healthcheck:
test: ["CMD", "curl", "-f", "http://kong:8001"]
interval: 5s
timeout: 2s
retries: 15
ports:
- "8001:8001"
- "8000:8000"
#######################################
# Konga database prepare
#######################################
konga-prepare:
image: pantsel/konga:next
command: "-c prepare -a postgres -u postgresql://kong@kong-database:5432/konga_db"
networks:
- kong-net
restart: on-failure
links:
- kong-database
depends_on:
- kong-database
#######################################
# Konga: Kong GUI
#######################################
konga:
image: pantsel/konga:next
restart: always
networks:
- kong-net
environment:
DB_ADAPTER: postgres
DB_HOST: kong-database
DB_USER: kong
TOKEN_SECRET: km1GUr4RkcQD7DewhJPNXrCuZwcKmqjb
DB_DATABASE: konga_db
NODE_ENV: production
depends_on:
- kong-database
ports:
- "1337:1337"
@lokeshsuhas

This comment has been minimized.

Copy link

commented Feb 28, 2019

Error creating a connection to Postgresql using the following settings:

@rjpalermo1

This comment has been minimized.

Copy link

commented Mar 1, 2019

yup

kong_kong-database_1    docker-entrypoint.sh postgres    Up (healthy)   0.0.0.0:5432->5432/tcp
kong_kong-migration_1   /docker-entrypoint.sh kong ...   Restarting                           
kong_kong_1             /docker-entrypoint.sh kong ...   Restarting                           
kong_konga-prepare_1    /app/start.sh -c prepare - ...   Exit 0                               
kong_konga_1            /app/start.sh                    Up             0.0.0.0:1337->1337/tcp
@juarrosluis

This comment has been minimized.

Copy link

commented Mar 9, 2019

Be careful on command: "kong migrations up"
Note for Kong < 0.15: with Kong versions below 0.15 (up to 0.14), use the up sub-command instead of bootstrap. Also note that with Kong < 0.15, migrations should never be run concurrently; only one Kong node should be performing migrations at a time. This limitation is lifted for Kong 0.15, 1.0, and above.

@shubhamoli

This comment has been minimized.

Copy link

commented Mar 20, 2019

Two fixes which worked for me.

Env:
OS - Amazon linux
Kong images version - latest

  1. kong migrations up >> kong migrations bootstrap . (newer versions of kong as mentioned by @juarrosluis)
  2. In the section where you define your kong service and under environment key, add KONG_DATABASE: postgres alongwith KONG_PG_HOST.
@iwanskit

This comment has been minimized.

Copy link

commented Apr 16, 2019

@shubhamoli I've tried to change kong migrations up to kong migrations bootstrap
but this is what I've get on kong-migration: No such command for migrations: bootstrap :(

@rakehell1986

This comment has been minimized.

Copy link

commented Jul 11, 2019

`
[root@smartagent-VODC sat-docker]# vi docker-compose.yml

image: cogniteev/echo
container_name: sat_db_data
command: echo 'Data Container for PostgreSQL'
volumes:
  - pg-data:/var/lib/postgresql/data

sat_kong:
build: ./kong
container_name: kong
command: "kong migrations bootstrap"
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=sat_db
- KONG_CASSANDRA_CONTACT_POINTS=sat_db
- KONG_PG_PASSWORD=*******
- KONG_PROXY_ACCESS_LOG=/dev/stdout
- KONG_ADMIN_ACCESS_LOG=/dev/stdout
- KONG_PROXY_ERROR_LOG=/dev/stderr
- KONG_ADMIN_ERROR_LOG=/dev/stderr
- KONG_ADMIN_LISTEN=0.0.0.0:8001,0.0.0.0:8444 ssl
ports:
- "8000:8000/tcp"
- "8001:8001/tcp"
- "8443:8443/tcp"
- "8444:8444/tcp"
depends_on:
- sat_db
restart: on-failure
links:
- sat_db

sat_konga:
image: pantsel/konga
container_name: konga
command: "-c prepare -a postgres -u postgresql://konga:@sat_db:5432/konga"
restart: on-failure
environment:
- TOKEN_SECRET=km1GUr4RkcQD7DewhJPNXrCuZwcKmqjb
- DB_ADAPTER=postgres
- DB_HOST=sat_db
- DB_PORT=5432
- DB_USER=konga
- DB_PASSWORD=

- DB_DATABASE=konga
- DB_PG_SCHEMA=public
- NODE_ENV=production
depends_on:
- sat_db
- sat_kong
ports:
- "1337:1337"
links:
- sat_db
- sat_kong`

@rakehell1986

This comment has been minimized.

Copy link

commented Jul 11, 2019

Hi please take the below configuration. it's always cant reach to success point.

kong /konga container are not up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.