在docker.yml文件中替换env varaible

发布于 2025-01-27 13:00:36 字数 894 浏览 5 评论 0原文

我在Docker容器中使用Kong db-db-necorrative模式:

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

和Docker-Compose环境变量,我

在Docker-entrypoint.sh中

#!/usr/bin/env bash

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

添加了myName = amin,我使用了 :但是, kong-template.yml中的Env变量,

例如

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

,Kong容器停止以退出误差。

有人知道有什么问题吗?

attaching to kong
kong existed with code 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文