<p>I've noticed a few different ways of setting commands and arguments for a Pod.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: busy
  name: busy
spec:
  containers:
  - args:
    - /bin/sh
    - -c
    - echo hello;sleep 3600
    image: busybox
    name: busy1
  - command: [&quot;/bin/sh&quot;]
    args:
    - -c
    - echo hello;sleep 3600
    image: busybox
    name: busy2
</code></pre>
<p>The above containers execute the same command/args, but one doesn't have <code>command</code> specified. Instead, the command is within <code>args</code>. Why is it possible to do this?</p>
<p>I also know that there is shell vs. exec form, and that exec form executes the command in the main process. What is the benefit of using either?</p>

KJ0797
<p><code>Command</code>: Controls the actual command run by the container image.</p>
<p><code>Args</code>: Controls the arguments passed to the command.</p>
<p><code>Kubernetes</code> allows you to override both the image’s default <code>command</code> (docker <code>Entrypoint</code>) and <code>args</code> (docker <code>Cmd</code>) with the <code>Command</code> and <code>Args</code> fields of <code>Container</code> in the <code>pod spec</code>.</p>
<p>As mentioned <a href="https://jamesdefabia.github.io/docs/user-guide/containers/#how-docker-handles-command-and-arguments" rel="nofollow noreferrer">here</a>:</p>
<ol>
<li>If you do not supply a <code>Command</code> or <code>Args</code> for a container, the defaults defined by the image will be used.</li>
<li>If you supply a <code>Command</code> but no <code>Args</code> for a container, only the supplied Command will be used; the image’s default arguments are ignored.</li>
<li>If you supply only <code>Args</code>, the image’s default command will be used with the arguments you supply.</li>
<li>If you supply a <code>Command</code> and <code>Args</code>, the image’s defaults will be ignored and the values you supply will be used</li>
</ol>
<p>By separating the <code>command</code> and <code>args</code> fields, <code>K8s</code> allows for more flexibility in defining the <code>command</code> to be executed inside the container. You can define a custom <code>command</code> and args` combination that is specific to your use case, and it can be different from the default command specified by the container image.</p>
<p>Hope it helps.</p>
