【问题标题】:command restriction in container Kubernetes容器 Kubernetes 中的命令限制
【发布时间】:2020-07-10 04:14:28
【问题描述】:

我想用命令行参数 --lines 56 -F 创建一个容器。

  1. 选项:为此我运行了命令 => k run app --image=lfccncf/arg-output --dry-run=client -o yaml > pod9.yaml

    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        run: app
      name: app
    spec:
      containers:
      - image: lfccncf/arg-output
        name: app
        args: ["--lines","56","F"]
    
  2. 选项:这是第二个选项如何完成任务。 kubectl run app1 --image=lfccncf/arg-output --dry-run=client --command ["--lines 56 -F"] -o yaml > pod9.yaml

我有这个限制“在创建你的 pod 时,你不需要指定容器命令,只需要 args”。对于上述限制,哪个选项是正确的?

【问题讨论】:

    标签: kubernetes kubernetes-container


    【解决方案1】:

    数字 1,因为您说您不需要指定命令,并且假设它已经预烘焙到容器映像中。 --lines 56 -F 是参数而不是“命令”

    引用自docs

    您在配置文件中定义的命令和参数会覆盖容器映像提供的默认命令和参数。如果您定义了 args,但未定义命令,则默认命令将与您的新参数一起使用。

    类似的工作方法是:

    $ kubectl run app1 --image=lfccncf/arg-output --dry-run=client -o yaml -- --lines 56 -F > pod9.yaml
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-03
      • 2015-05-12
      • 2021-07-10
      • 2016-03-02
      • 1970-01-01
      • 2022-10-21
      • 1970-01-01
      相关资源
      最近更新 更多