Back-off restarting failed container openshift kubernetes

11/6/2019

I have a Dockerfile running Kong-api to deploy on openshift. It build okay, but when I check pods I get Back-off restarting failed container. Here is my dockerfile

FROM ubuntu:18.04
RUN apt-get update && apt-get install -y apt-transport-https curl lsb-core
RUN echo "deb https://kong.bintray.com/kong-deb `lsb_release -sc` main" | tee -a /etc/apt/sources.list
RUN curl -o bintray.key https://bintray.com/user/downloadSubjectPublicKey?username=bintray
RUN apt-key add bintray.key
RUN apt-get update && apt-get install -y kong

COPY kong.conf /etc/kong/
RUN kong migrations bootstrap [-c /etc/kong/kong.conf]

EXPOSE 8000 8443 8001 8444
ENTRYPOINT ["kong", "start", "[-c /etc/kong/kong.conf]"]

Where is my wrong? Please help me. Thanks in advance

-- Akashii
docker
kubernetes
openshift

1 Answer

11/6/2019

In order to make the kong start correctly, you need to execute these commands when you have an active Postgres connection:

kong migrations bootstrap && kong migrations up

Also, note that the format of the current Dockerfile is not valid if you would like to pass options within the ENTRYPOINT you can write it like that:

ENTRYPOINT ["kong", "start","-c", "/etc/kong/kong.conf"]

Also, you need to remove this line:

RUN kong migrations bootstrap [-c /etc/kong/kong.conf]

Note that the format of the above line is not valid as RUN expects a normal shell command so using [] in this case is not correct.

So as you deploy to Openshift there are several ways to achieve what you need.

-- Mostafa Hussein
Source: StackOverflow