<p>I am preparing for the CKAD exam and I am doing practice with the questions provide <a href="https://github.com/dgkanatsios/CKAD-exercises/blob/master/c.pod_design.md" rel="nofollow noreferrer">here</a></p>
<p>I have a doubt over this two different way of executing commands. Here the example provided is with a job but I think the question might be more general and extendable to all containers.</p>
<p>Under the job exercises there are two requests:</p>
<p><a href="https://github.com/dgkanatsios/CKAD-exercises/blob/master/c.pod_design.md#create-a-job-named-pi-with-image-perl-that-runs-the-command-with-arguments-perl--mbignumbpi--wle-print-bpi2000" rel="nofollow noreferrer"><em>Create a job named pi with image perl that runs the command with arguments &quot;perl -Mbignum=bpi -wle 'print bpi(2000)'&quot;</em></a></p>
<pre><code>kubectl create job pi  --image=perl -- perl -Mbignum=bpi -wle 'print bpi(2000)'
</code></pre>
<p><a href="https://github.com/dgkanatsios/CKAD-exercises/blob/master/c.pod_design.md#create-a-job-with-the-image-busybox-that-executes-the-command-echo-hellosleep-30echo-world" rel="nofollow noreferrer"><em>Create a job with the image busybox that executes the command 'echo hello;sleep 30;echo world</em></a></p>
<pre><code>kubectl create job busybox --image=busybox -- /bin/sh -c 'echo hello;sleep 30;echo world'
</code></pre>
<p>Why in the second command I need to provide /bin/sh -c as well?</p>
<p>How could I understand when to use it and when not?</p>

Cr4zyTun4
<p>Because in first example</p>
<pre><code>kubectl create job pi  --image=perl -- perl -Mbignum=bpi -wle 'print bpi(2000)'
</code></pre>
<p>you call a <code>perl</code> interpreter, <code>perl -Mbignum=bpi -wle 'print bpi(2000)'</code></p>
<p>and in second example you call a bash shell command, <code>echo hello;sleep 30;echo world</code> therefore <code>/bin/sh -c</code></p>
<pre><code>kubectl create job busybox --image=busybox -- /bin/sh -c 'echo hello;sleep 30;echo world'
</code></pre>
<p>The <code>--</code> is saying after this it is a command is executed inside the container.</p>
