问题描述
我在Docker映像中有一个bash脚本,可以通过 docker run
向其传递命令行参数(已在 ENTRYPOINT
中指定了bash脚本和默认参数)在 CMD
中使用,就像在 answer 中一样.所以我会运行类似的
I have a bash script in a Docker image to which I can pass a command line argument through docker run
(having specified the bash script in ENTRYPOINT
and a default parameter in CMD
like in this answer). So I would run something like
docker run my_docker_test argument_1
现在,我想将多个(大约50个)容器部署到OpenShift或Kubernetes,每个容器具有不同的参数值.我知道在Kubernetes中我可以在对象配置yaml文件中指定 command
和 args
.是否有可能像 docker run
中那样直接从命令行传递参数,例如传递给 kubectl
或 oc
,而无需每次我想更改参数值时都创建新的Yaml文件吗?
Now I would like to deploy multiple (ca. 50) containers to OpenShift or Kubernetes, each with a different value of the argument. I understand that in Kubernetes I could specify the command
and args
in the object configuration yaml file. Is there a possibility to pass the argument directly from the command line like in docker run
, e.g. passing to kubectl
or oc
, without the need to create a new yaml file each time I want to change the value of the argument?
推荐答案
以下命令应执行以下操作:
The following command should do it:
kubectl run my-app --image=my_docker_test -- argument_1
这篇关于如何通过命令行将参数传递给Kubernetes或OpenShift中的Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!