How to fix Database needs bootstrapping or is older than Kong 1.0

How to fix this error? nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:16: Database needs bootstrapping or is older than Kong 1.0. To start a new installation from scratch, run 'kong migrations bootstrap'. To migrate from a version older than 1.0, migrated to Kong 1.5.0 first. If you still have 'apis' entities, you can convert them to Routes and Services using the 'kong migrations migrate-apis' command in Kong 1.5.0. stack traceback: [C]: in function 'error' /usr/local/share/lua/5.1/kong/cmd/utils/migrations.lua:16: in function 'check_state' /usr/local/share/lua/5.1/kong/init.lua:562: in function 'init' init_by_lua:3: in main chunk

dockerfile files

FROM python:3.10
 
WORKDIR /app
 
COPY requirements.txt .
RUN pip install -r requirements.txt
 
EXPOSE 8000
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]

docker-compose files

version: '3.9'
services:
  kong-database:
    image: postgres:latest
    container_name: kong-database
    restart: always
    ports:
      - 15432:5432
    networks:
      - default
    volumes:
      - db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=kong
      - POSTGRES_USER=kong
      - POSTGRES_PASSWORD=kong

  kong:
    image: kong:latest
    container_name: kong
    restart: always
    ports:
      - 18000:8000
      - 18443:8443
      - 127.0.0.1:8001:8001
      - 18444:8444
    links:
      - kong-database:kong-database
    networks:
      - default
    environment:
      - LC_CTYPE=en_US.UTF-8
      - LC_ALL=en_US.UTF-8
      - KONG_DATABASE=postgres
      - KONG_PG_HOST=kong-database
      - KONG_PG_USER=kong
      - KONG_PG_PASSWORD=kong
      - KONG_CASSANDRA_CONTACT_POINTS=kong-database
      - 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:18001, 0.0.0.0:18444 ssl
    
  konga:
    image: pantsel/konga
    container_name: kong-konga
    restart: always
    ports:
      - 1337:1337
    networks:
      - default
    volumes:
      - data:/app/kongadata
    links:
      - kong:kong
    environment:
      - NODE_ENV=production

networks:
  default:
    driver: bridge

volumes:
  db:
    driver: local
  data:
    driver: local

setting.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'kong',
        'USER': 'kong',
        'PASSWORD': 'kong',
        'HOST': '127.0.0.1',
        'PORT': '15432',
    }
}

You can just start postgresql and do the migration with docker command then use your docker compose

Start postgresql:

docker compose up kong-database

then do the migration

docker run --rm --network=default \
  -e "KONG_PG_HOST=kong-database" \
  -e "KONG_DATABASE=kong"         \
  -e "KONG_PG_PASSWORD=kong"      \
  -e "KONG_PASSWORD=kong"         \
 kong:latest kong migrations bootstrap

And finally start kong and konga

docker compose up kong konga

Or you can add a kong-migration use the profile donotstart to not start it by default

  kong-migration:
    image: kong:latest
    command: "kong migrations bootstrap"
    networks:
      - default
    restart: on-failure
    environment:
      - KONG_PG_HOST=kong-database
      - KONG_PG_USER=kong
      - KONG_PG_PASSWORD=kong
    links:
      - kong-database
    depends_on:
      - kong-database
    profiles:
      - donotstart

then

docker compose up kong-migration

and finally

docker compose up
Back to Top