gpt4 book ai didi

python - 如何将命令行参数从 oc start-build 传递到 dockerfile 以在 dockerfile 内设置环境变量

转载 作者:行者123 更新时间:2023-12-01 06:25:03 26 4
gpt4 key购买 nike

使用了以下命令,但环境值未在 Dockerfile 中传递。通过groovy脚本在oc容器中运行这些实例:

oc start-build -eenvironment=ipte2 ipte2-isell-api-7 --from-dir=./isell-python-wrapper --follow=true

**WARNING**: Specifying environment variables with binary builds is not supported.
Uploading directory "isell-python-wrapper" as binary input for the build ...
build "ipte2-isell-api-7-1" started
2)oc start-build --build-arg environment=ipte2 ipte2-isell-api-5 --from-dir=./isell-python-wrapper --follow=true

**WARNING**: Specifying build arguments with binary builds is not supported.
Uploading directory "isell-python-wrapper" as binary input for the build ...
build "ipte2-isell-api-5-1" started

error
Removing intermediate container f7ff031b18b1
Step 35/44 : COPY script/${environment}-local.conf /sum/lpp/ebb/local.conf
error: build error: lstat script/-local.conf: no such file or directory

Dockerfile

FROM wlp-base:0.1 #from statement base image
ARG environment

ENV environment=${environment}

COPY script/${environment}-local.conf

我需要在复制命令中传递上述环境值如果我通过ENV环境=ipte2直接在 Dockerfile 中工作正常。但是发送命令行参数,它没有得到它。

最佳答案

您可以尝试使用 BuildConfig(例如使用 yaml python 包)自动编辑 YAML list 文件,以将条目添加到 buildArgs 数组,位于 BuildConfigdockerStrategy 定义中。例如:

dockerStrategy:
...
buildArgs:
- name: "foo"
value: "bar"

请参阅relevant Openshift docs了解更多详情。

关于python - 如何将命令行参数从 oc start-build 传递到 dockerfile 以在 dockerfile 内设置环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60202086/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com