<p>Newbie here, I am trying to run two containers in a pod. I need them in the &quot;dev&quot; namespace.
Here is my YAML:</p>
<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: test-deployment
  namespace: dev
spec:
  selector:
    matchLabels:
      deploy: example
  template:
    metadata:
      labels:
        deploy: example
    spec:
      containers:
        - name: nginx
          image: nginx:latest
        - name: busybox
          image: busybox:1.34
</code></pre>
<p>I got this error:</p>
<blockquote>
<p>CrashLoopBackOff</p>
</blockquote>
<p>kubectl describe pod gives me this result:</p>
<pre><code>Events:
  Type     Reason     Age                   From               Message
  ----     ------     ----                  ----               -------
  Normal   Scheduled  8m14s                 default-scheduler  Successfully assigned dev/nginx-deployment-55fd86946-hgjlk to minikube
  Normal   Pulling    8m13s                 kubelet            Pulling image &quot;nginx:latest&quot;
  Normal   Pulled     8m8s                  kubelet            Successfully pulled image &quot;nginx:latest&quot; in 4.9201206s
  Normal   Created    8m8s                  kubelet            Created container nginx
  Normal   Started    8m8s                  kubelet            Started container nginx
  Normal   Pulling    8m8s                  kubelet            Pulling image &quot;busybox:1.34&quot;
  Normal   Pulled     8m3s                  kubelet            Successfully pulled image &quot;busybox:1.34&quot; in 5.2652786s
  Normal   Created    7m16s (x4 over 8m3s)  kubelet            Created container busybox
  Normal   Started    7m16s (x4 over 8m3s)  kubelet            Started container busybox
  Normal   Pulled     7m16s (x3 over 8m2s)  kubelet            Container image &quot;busybox:1.34&quot; already present on machine
  Warning  BackOff    3m3s (x23 over 8m1s)  kubelet            Back-off restarting failed container
</code></pre>
<p>So what am I doing wrong? Tried to run different images, I got the same error. Is it even possible to run two containers in a pod through <strong>kind:Deployment</strong> or I should use <strong>kind:Pod</strong> and specify them that way?</p>

pysquirrel
<p>Your busybox container is crashing because it needs a process to run for indefinite period. As long as a process is running  inside, the container won't crash (unless there's some un-handled exception). BusyBox image doesn't come with a default process.</p>
<p>Just add <code>command</code> attribute with <code>sleep</code> in your busybox container.</p>
<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: test-deployment
  namespace: dev
spec:
  selector:
    matchLabels:
      deploy: example
  template:
    metadata:
      labels:
        deploy: example
    spec:
      containers:
        - name: nginx
          image: nginx:latest
        - name: busybox
          image: busybox:1.34
          command: [&quot;sh&quot;, &quot;-c&quot;, &quot;sleep 3600&quot;] # run sleep command for 3600 seconds / 1 hr
</code></pre>
