Kubernetes - Passing multiple commands to the container

11/29/2015

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?

-- Dimuthu
kubernetes

2 Answers

11/29/2015

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

-- Jordan Liggitt
Source: StackOverflow

1/11/2019

use this command

command: ["/bin/sh","-c"]
args: ["command one; command two && command three"]
-- brian
Source: StackOverflow