<p>I'm trying to understand what is the correct usage of command in Pods. Taking below example of my yaml. This is a working YAML. My doubts are</p>
<p>1&gt; the sleep command is issued for 3600 seconds, but my pod busybox2 is still running after few hours when I see pods via 'k get pods'. My current understanding is, the sleep should execute for 3600 seconds and the pod is supposed to die out after that, as there is no process running my Pod (like httpd, nginx etc). Not sure why this is</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: busybox2
  namespace: default
spec:
  containers:
  - name: busy
    image: busybox
    command:
      - sleep
      - &quot;3600&quot; 
</code></pre>
<p>2&gt; When checked on k8s docs, the usage shows a different way to write it. I understand that cmd and the args are separate things.. but can I not simply use both ways for all scenarios? like writing command: [&quot;sleep&quot;, &quot;3600&quot;] as first example, and <code>command: - printenv \ - HOSTNAME</code> as another way to write second yaml command section. Can someone elaborate a bit.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: command-demo
  labels:
    purpose: demonstrate-command
spec:
  containers:
  - name: command-demo-container
    image: debian
    command: [&quot;printenv&quot;]
    args: [&quot;HOSTNAME&quot;, &quot;KUBERNETES_PORT&quot;]
  restartPolicy: OnFailure
</code></pre>

<p><code>...but my pod busybox2 is still running after few hours...</code></p>
<p>This is because the default value for <code>restartPolicy</code> is <code>Always</code>. Means after an hour, your pod actually restarted.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: busybox2
  namespace: default
spec:
  restartPolicy: OnFailure  # &lt;-- Add this line and it will enter &quot;Completed&quot; status.
  containers:
  - name: busy
    image: busybox
    command:
      - sleep
      - &quot;10&quot;  # &lt;-- 10 seconds will do to see the effect.
</code></pre>
<p>See <a href="https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes" rel="nofollow noreferrer">here</a> for how K8s treats entrypoint, command, args and CMD.</p>
