Kong: Kong does not Start in a Docker Container

Created on 3 Oct 2017  路  12Comments  路  Source: Kong/kong

When Running through the steps of your example tutorial on how to start docker, the docker container hangs on the run command.

The only output to the console is:
prefix directory /usr/local/kong not found, trying to create it

Why does your example not work?

pending author feedback

Most helpful comment

Try : https://github.com/Mashape/docker-kong/tree/master/compose
It works for me.
However the challenge is with the memory leak

All 12 comments

Can you please detail the exact steps you've taken to start Kong, from start to finish? I suspect you've simply missed a documented step in the process :)

I sure can:

On MacOS:

Step 1) I run:
docker run -d --name kong-database -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" postgres:9.4

Step 2) I run:
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:latest kong migrations up

Step 3) I run:
docker run --name kong --link kong-database:kong-database -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong

I am running against this tutorial, which has 3 steps:
https://hub.docker.com/_/kong/

I don't get this error when using the Cassandra version.

It is unique to postgres.

Can you try removing the Postgres image entirely and re-grabbing it from scratch?

Yes. Same result.

Same result when I reset my docker installation to factory settings.

Can you share the output of docker logs?

When running the docker logs command, the only output is

prefix directory /usr/local/kong not found, trying to create it

I followed the same steps (not on a mac) but was successful.

docker run -d --name kong \
--link kong-database:kong-database \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database"\
 -p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
kong

ubuntu@ip-172-31-24-121:~$ curl -i http://localhost:8001/
HTTP/1.1 200 OK
Date: Tue, 03 Oct 2017 14:50:35 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.11.0

can you run ps -aux against the Kong container

docker exec -t kong ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1 212684 12328 ?        Ss   14:49   0:00 nginx: master p
nobody      48  0.0  0.3 231328 28460 ?        S    14:49   0:00 nginx: worker p
nobody      49  0.0  0.3 231652 28676 ?        S    14:49   0:00 nginx: worker p
root        50  0.0  0.0  47460  3372 ?        Rs+  14:53   0:00 ps aux

I have executed the exact same steps and it works for me.

$ docker run -d --name kong-database -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" postgres:9.4
[...]
$ 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:latest kong migrations up
[...]
$ docker run --name kong --link kong-database:kong-database -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -p 8000:8000 -p 8443:8443 -p 8001:8001 -p 8444:8444 kong
prefix directory /usr/local/kong not found, trying to create it

and properly working when using Kong.

Try : https://github.com/Mashape/docker-kong/tree/master/compose
It works for me.
However the challenge is with the memory leak

@charliecliff Note that @thefosk got the same output as you and the instance is working.

Perhaps what you perceived as Kong "hanging" was just that it is running in the foreground? Try adding parameter -d to the docker command in step 3 and it should detach into the background. Then try playing around with it using curl, following the next steps of the tutorial.

I believe @hishamhm's assumption is correct. Starting the Kong container without the -d option gives me the same result. It is also how you started your Kong container according to your initial comment in this thread.

I believe we have answered your question at this point. In the future, please do keep in mind that our GitHub issues are intended for bug reports only, and try to seek help from other community support channels like the Gitter chat or the mailing list (see README.md), thanks!

Was this page helpful?
0 / 5 - 0 ratings