0

I have a docker file as below:

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"]
# ENTRYPOINT ["/docker-entrypoint.sh"]


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

and the docker-entrypoint.sh is

#!/usr/bin/env bash

echo "Hello World"

also I have a docker-compose file as below

version: "3.8"

networks:
 kong-net:
  name: kong-net
  driver: bridge
  ipam:
    config:
      - subnet: 172.1.1.0/24

services:
  kong:
    container_name: kong
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      kong-net:
        ipv4_address: 172.1.1.40
    healthcheck:
      test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
      interval: 5s
      timeout: 2s
      retries: 15
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - 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_DECLARATIVE_CONFIG=/kong/declarative/kong.yml
      - MYNAME=amin
    ports:
      - "8444:8444"
      - "80:8000"
      - "443:8443"
      - "8001:8001"

When I run docker-compose up --build it runs fine as expected but if I uncomment the three lines in the docker-file and run docker-compose up --build this is the result

enter image description here

What is it that I am doing wrong? How should I fix it? I need to run a command in the docker container in the run stage before it is started. How should I do this?

Amin Ba
  • 1,603
  • 1
  • 13
  • 38

0 Answers0