<p>I want to execute a command during the creation of the pod.
I see two options available :</p>
<p><code>kubectl run busybox --image=busybox --restart=Never -- sleep 3600</code></p>
<p><code>kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c &quot;sleep 3600&quot;</code></p>
<p>What is the difference between the above two commands ?</p>

Karthik Rao V
<ul>
<li><p>In short no difference in the outcome if you want to run &quot;sleep 3600&quot;.
Both perform the same operation.</p>
</li>
<li><p>To understand the behaviour of those options add dry-run option to it</p>
</li>
<li><p>First one passes &quot;sleep&quot; &amp; &quot;3600&quot; as arguments to Entrypoint of busybox image which is &quot;/bin/sh&quot;</p>
</li>
</ul>
<pre><code>kubectl run busybox --image=busybox --restart=Never --dry-run=client -o yaml -- sleep 3600
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox
spec:
  containers:
  - args:
    - sleep
    - &quot;3600&quot;
    image: busybox
    name: busybox
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
</code></pre>
<ul>
<li>second one passes &quot;/bin/sh -c&quot; , &quot;sleep&quot; &amp; &quot;3600&quot; as arguments to Entrypoint of busybox image which is &quot;/bin/sh&quot; . So it will open a new shell to run &quot;sleep 3600&quot; inside the container.</li>
</ul>
<pre><code>kubectl run busybox --image=busybox --restart=Never --dry-run=client -o yaml -- /bin/sh -c &quot;sleep 3600&quot;
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busybox
  name: busybox
spec:
  containers:
  - args:
    - /bin/sh
    - -c
    - sleep 3600
    image: busybox
    name: busybox
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}
</code></pre>
<ul>
<li>As mentioned in the beginning it does not make any difference in the outcome of &quot;sleep 3600&quot; But this method is useful when you want to run multiple commands by container for example &quot;sleep 3600&quot; &amp; &quot;echo boo&quot;. so the syntax would be</li>
</ul>
<pre><code>kubectl run busybox --image=busybox --restart=Never -- /bin/sh -c &quot;sleep 3600;echo boo&quot;
</code></pre>
