Kubernetes-将多个命令传递给容器 [英] Kubernetes - Passing multiple commands to the container

查看:102
本文介绍了Kubernetes-将多个命令传递给容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在kubernetes配置文件的command标记中向Docker容器发送多个入口点命令.

I want send multiple entrypoint commands to a Docker container in the command tag of kubernetes config file.

apiVersion: v1
kind: Pod
metadata:
  name: hello-world
spec:  # specification of the pod’s contents
  restartPolicy: Never
  containers:
  - name: hello
    image: "ubuntu:14.04"
    command: ["command1 arg1 arg2 && command2 arg3 && command3 arg 4"]

但似乎不起作用.在命令标签中发送多个命令的正确格式是什么?

But it seems like it does not work. What is the correct format of sending multiple commands in the command tag?

推荐答案

容器中只能有一个入口点...如果要运行多个这样的命令,请将bash用作入口点,然后将所有其他命令是bash运行的参数:

There can only be a single entrypoint in a container... if you want to run multiple commands like that, make bash be the entry point, and make all the other commands be an argument for bash to run:

command: ["/bin/bash","-c","touch /foo && echo 'here' && ls /"]

这篇关于Kubernetes-将多个命令传递给容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆