Reputation:
im trying to set up Kong for my company, i followed the instruction from Kong documentation.
first i run this command:
docker network create kong-net
and then this command:
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
-e "POSTGRES_PASSWORD=kong" \
postgres:9.6
according to documentation, next step is run the migration with this command
docker run --rm --network=kong-net -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_PG_USER=kong" -e "KONG_PG_PASSWORD=kong" kong:latest kong migrations up
but it keeps giving me this error
Error: missing database for connect
full log
Error:
/usr/local/share/lua/5.1/pgmoon/init.lua:547: missing database for connect
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/pgmoon/init.lua:547: in function 'send_startup_message'
/usr/local/share/lua/5.1/pgmoon/init.lua:207: in function 'connect'
.../share/lua/5.1/kong/db/strategies/postgres/connector.lua:202: in function 'connect'
.../share/lua/5.1/kong/db/strategies/postgres/connector.lua:489: in function 'query'
.../share/lua/5.1/kong/db/strategies/postgres/connector.lua:270: in function 'init'
/usr/local/share/lua/5.1/kong/db/init.lua:138: in function 'init_connector'
/usr/local/share/lua/5.1/kong/cmd/migrations.lua:95: in function 'cmd_exec'
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:88>
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/kong/cmd/init.lua:88: in function </usr/local/share/lua/5.1/kong/cmd/init.lua:45>
/usr/local/bin/kong:9: in function 'file_gen'
init_worker_by_lua:48: in function <init_worker_by_lua:46>
[C]: in function 'xpcall'
init_worker_by_lua:55: in function <init_worker_by_lua:53>
2020/07/23 03:38:40 [verbose] no config file found at /etc/kong/kong.conf
2020/07/23 03:38:40 [verbose] no config file found at /etc/kong.conf
2020/07/23 03:38:40 [verbose] no config file, skip loading
2020/07/23 03:38:40 [verbose] prefix in use: /usr/local/kong
where did i go wrong ?
Upvotes: 1
Views: 1489
Reputation: 30090
Please follow this
Step : 1
docker run -d --name kong-database \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
postgres:9.6
Step : 2
docker run --rm \
--link kong-database:kong-database \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
kong kong migrations up
Step : 3
docker run -d --name kong \
--link kong-database:kong-database \
-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
you can also use this docker-compose if you don't have any issue
Updated
version: "2"
services:
kong-database:
image: postgres:9.6
container_name: kong-database
ports:
- 5432:5432
environment:
POSTGRES_DB: kong
POSTGRES_USER: kong
POSTGRES_PASSWORD: kong
kong:
image: kong:latest
command: "kong migrations bootstrap"
restart: always
links:
- kong-database:kong-database
ports:
- 8000:8000
- 8443:8443
- 8001:8001
- 7946:7946
- 7946:7946/udp
environment:
- KONG_DATABASE=postgres
- KONG_PG_HOST=kong-database
- KONG_PG_PASSWORD=kong
- KONG_PG_USER=kong
if you require version 3.7 of docker compose
https://stackoverflow.com/a/60511959/5525824
Upvotes: 1