0

I am using kong db-less declarative mode in a docker container as below:

Dockerfile

FROM kong
USER 0

RUN mkdir -p /kong/declarative/
COPY declarative/kong.yml /kong/declarative/

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN ["chmod", "+x", "/docker-entrypoint.sh"]

RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf

RUN apk add gettext

and in the docker-compose environment variable, I add MYNAME=amin

In docker-entrypoint.sh I have:

#!/usr/bin/env bash

envsubst < /kong/declarative/kong-template.yml > /kong/declarative/kong.yml

And I use the env variable in kong-template.yml

for example

    routes:
      - name: gamma
        methods:
          - GET
        paths:
          - /$MYNAME/gamma
        strip_path: true

However, the kong container stops with an exit error.

Does anybody know what is the problem?

attaching to kong
kong existed with code 0
Amin Ba
  • 1,603
  • 1
  • 13
  • 38
  • Is that the entire entrypoint script? The container will run the entirety of that script, and then exit; you may need to make sure it ends with the command `exec "$@"` to have it replace itself with the Dockerfile `CMD`. (The Dockerfile you included looks like it's missing the `ENTRYPOINT` and `CMD` declarations at the end.) – David Maze May 10 '22 at 01:28
  • yes that is the whole dockerfile and docker-entrypoint.sh - I also have a docker-compose file – Amin Ba May 10 '22 at 02:07
  • @DavidMaze This is a related question. can you please check? https://stackoverflow.com/questions/72185730/how-to-run-echo-hello-world-when-just-starting-a-container – Amin Ba May 10 '22 at 12:46
  • What's causing these containers to write out PNG files? In both cases, you're overwriting the entrypoint with a very short script that does one thing and then exits, and when the entrypoint script completes, the container exits too. – David Maze May 10 '22 at 14:20
  • the png file is a capture of the terminal logs I have shared here. There is no png file. how can I achieve what I want to do here or https://stackoverflow.com/questions/72185730/how-to-run-echo-hello-world-when-just-starting-a-container – Amin Ba May 10 '22 at 14:24
  • I need one line of code to run when container starts and i want everything else the same – Amin Ba May 10 '22 at 14:25
  • Please don't paste screen shots of terminal windows into Stack Overflow questions: they're hard to read and search on later. Paste the actual text of the container output instead, maybe into a code block. – David Maze May 10 '22 at 14:31
  • try to use this entrypoint script and update it for your need https://github.com/Kong/docker-kong/blob/master/docker-entrypoint.sh – Ôrel May 10 '22 at 19:46
  • I finally reached to this and did that and it is working! – Amin Ba May 10 '22 at 20:15

0 Answers0