Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have setup kong docker container. it's starting with docker compose file:

kong:
image: "${KONG_DOCKER_TAG}" 
user: ${KONG_USER}
depends_on:
  - kong-database
  - kong-migrations
environment:
  KONG_ADMIN_ACCESS_LOG: /dev/stdout
  KONG_ADMIN_ERROR_LOG: /dev/stderr
  KONG_ADMIN_LISTEN: '0.0.0.0:8001'
  KONG_CASSANDRA_CONTACT_POINTS: ${KONG_CASSANDRA_CONTACT_POINTS}
  KONG_DATABASE: ${KONG_DATABASE}
  KONG_PG_DATABASE: ${KONG_PG_DATABASE}
  KONG_PG_HOST: ${KONG_PG_HOST}
  KONG_PROXY_LISTEN: '0.0.0.0:8000'
  KONG_PROXY_LISTEN_SSL: 0.0.0.0:8443
  KONG_NGINX_HTTP_INCLUDE: custom-nginx-kong.conf
  KONG_PG_USER: ${KONG_PG_USER}
  KONG_PROXY_ACCESS_LOG: /dev/stdout
  KONG_PROXY_ERROR_LOG: /dev/stderr
  KONG_PG_PASSWORD: ${KONG_PG_PASSWORD}
networks:
  - external-network
configs: 
  - source: kong-config
    target: /usr/local/kong/custom-nginx-kong.conf
    # Permissions -r--r--r--
    mode: 0444
healthcheck:
  test: ["CMD", "curl", "-f", "http://kong:8001"]
  interval: 5s
  timeout: 2s
  retries: 15
restart: on-failure
deploy:
  restart_policy:
    condition: on-failure
  labels:
    com.docker.lb.hosts: ${APP_URL_KONG}
    com.docker.lb.port: 8080
    com.docker.lb.network: external-network
    com.docker.lb.backend_mode: vip

I want to execute curl commands eg. to add new service in kong like below post command immediately after my container is created automatically either through some script or using the below command. but How can I setup this automation through above docker-compose file? please help me to add services automatically on startup though docker compose!!!

curl -i -X POST http://<admin-hostname>:8001/services 
  --data name=example_service 
  --data url='http://mockbin.org'

Thanks in advance!

question from:https://stackoverflow.com/questions/65837405/how-to-run-curl-commands-inside-kong-docker-container-at-startup

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...