Kubernetes - Passing multiple commands to the cont

2020-05-19 02:28发布

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?

标签: kubernetes
2条回答
看我几分像从前
2楼-- · 2020-05-19 03:11

use this command

command: ["/bin/sh","-c"]
args: ["command one; command two && command three"]
查看更多
可以哭但决不认输i
3楼-- · 2020-05-19 03:27

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 /"]

查看更多
登录 后发表回答