<p>People,
I am trying to create a simple file <em>/tmp/tarte.test</em> with initContainers. I have a constraint, using an alpine image for the container. Please let me know what is NOT in this simple yaml file. </p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: initonpod
  namespace: prod
  labels:
    app: myapp
spec:
  containers:
  - name: mycont-nginx
    image: alpine
  initContainers:
    - name: myinit-cont
      image: alpine
      imagePullPolicy: IfNotPresent
      command: 
      - touch
      - "/tmp/tarte.test"
      - sleep 200
</code></pre>

<p>the describe of the pod</p>

<pre><code>Events:
  Type     Reason     Age              From                 Message
  ----     ------     ----             ----                 -------
  Normal   Scheduled  9s               default-scheduler    Successfully assigned prod/initonpod to k8s-node-1
  Normal   Pulled     8s               kubelet, k8s-node-1  Container image "alpine" already present on machine
  Normal   Created    8s               kubelet, k8s-node-1  Created container
  Normal   Started    7s               kubelet, k8s-node-1  Started container
  Normal   Pulling    4s (x2 over 7s)  kubelet, k8s-node-1  pulling image "alpine"
  Normal   Pulled     1s (x2 over 6s)  kubelet, k8s-node-1  Successfully pulled image "alpine"
  Normal   Created    1s (x2 over 5s)  kubelet, k8s-node-1  Created container
  Normal   Started    1s (x2 over 5s)  kubelet, k8s-node-1  Started container
  Warning  BackOff    0s               kubelet, k8s-node-1  Back-off restarting failed container
</code></pre>

<p>And if I change the alpine image for an nginx image container... it's work good.</p>

<p><code>Back-off restarting failed container</code> because of your container spec.</p>

<pre><code>spec:
  containers:
  - name: mycont-nginx
    image: alpine
</code></pre>

<p>This <code>alpine</code> container doesn't run forever. In kubernetes, container has to run forever.That's why you are getting error. When you use <code>nginx</code> image, it runs forever. So to use <code>alpine</code> image change the spec as below:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: busypod
  labels:
    app: busypod
spec:
  containers:
  - name: busybox
    image: alpine
    command:
    - "sh"
    - "-c"
    - &gt;
      while true; do
        sleep 3600;
      done
  initContainers:
  - name: myinit-cont
    image: alpine
    imagePullPolicy: IfNotPresent
    command:
    - touch
    - "/tmp/tarte.test"
    - sleep 200
</code></pre>
