<p>I was trying to create a pod using yaml file, that can run few commands as soon as it started. The yaml files looks like:</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: testmultiplecmds
spec:
  restartPolicy: Never
  containers:
  - name: nginxmultiplecmds
    image: nginx
    command:
    - &quot;/bin/bash&quot;
    - -c
    - &quot;ls -ltr&quot;
    - &quot;/bin/bash&quot;
    - -c
    args:
    - &quot;date ; sleep 36&quot;
</code></pre>
<p>but everytime I run this, it only outputs the results of /bin/bash -c ls -ltr, which is basically the first command and everything else is ignored. I tried multiple combination like:</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: testmultiplecmds
spec:
  restartPolicy: Never
  containers:
  - name: nginxmultiplecmds
    image: nginx
    command:
    - &quot;/bin/bash&quot;
    - -c
    args:
    - &quot;date ;&quot;
    - &quot;sleep 30&quot;
</code></pre>
<p>but in this also, it just prints out the date and does not sleep.
But when I do:</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: testmultiplecmds
spec:
  restartPolicy: Never
  containers:
  - name: nginxmultiplecmds
    image: nginx
    command:
    - &quot;/bin/bash&quot;
    - -c
    args:
    - &quot;date ; sleep 30&quot;
</code></pre>
<p>it works.</p>
<p>So my question is, Why we cannot run multiple commands (specified in different lines as different items not under single string) even though <strong>commands</strong> and <strong>args</strong> takes []String and if we cannot run multiple commands, then why they take []String, they should simply take String?</p>

AnxiousGuy
<p>It works fine.</p>
<pre class="lang-yaml prettyprint-override"><code>kind: Pod
apiVersion: v1
metadata:
  name: testmultiplecmds
spec:
  restartPolicy: Never
  containers:
  - name: nginxmultiplecmds
    image: nginx
    command: [&quot;/bin/bash&quot;, &quot;-c&quot;]
    args: [&quot;date; sleep 30&quot;]
</code></pre>
<p><code>[&quot;/bin/bash&quot;, &quot;-c&quot;]</code> meaning run a bash to execute following instructions. And passed commands by args. The args are then passed as commands to the bash. Commnads are separated in args by semicolon.</p>
<h1>update</h1>
<p>for multiline you can give args like this way, every command should end with a semicolon.</p>
<pre><code>args:
   - date;
     sleep 10;
     echo done;
</code></pre>
