<p>I keep seeing <code>Back-off restarting failed container</code> when try to use docker official image <a href="https://hub.docker.com/_/hello-world" rel="nofollow noreferrer">https://hub.docker.com/_/hello-world</a> to create any pod\deployment. When I switch to other images like <code>nginx</code> everything works well.</p>
<p>How can I debug and fix this issue?</p>
<p>Below are the event logs after creating the pod with <code>kubectl</code>.</p>
<pre><code>root@ip-10-229-68-221:~# kubectl get event --watch
LAST SEEN   TYPE      REASON              OBJECT                             MESSAGE
24s         Normal    Scheduled           pod/helloworld-656898b9bb-98vrv    Successfully assigned default/helloworld-656898b9bb-98vrv to kind-lab-worker
23s         Normal    Pulling             pod/helloworld-656898b9bb-98vrv    Pulling image &quot;hello-world:linux&quot;
16s         Normal    Pulled              pod/helloworld-656898b9bb-98vrv    Successfully pulled image &quot;hello-world:linux&quot; in 7.371731633s
1s          Normal    Created             pod/helloworld-656898b9bb-98vrv    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-98vrv    Started container hello-world
1s          Normal    Pulled              pod/helloworld-656898b9bb-98vrv    Container image &quot;hello-world:linux&quot; already present on machine
13s         Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
24s         Normal    Scheduled           pod/helloworld-656898b9bb-sg6fs    Successfully assigned default/helloworld-656898b9bb-sg6fs to kind-lab-worker
23s         Normal    Pulling             pod/helloworld-656898b9bb-sg6fs    Pulling image &quot;hello-world:linux&quot;
13s         Normal    Pulled              pod/helloworld-656898b9bb-sg6fs    Successfully pulled image &quot;hello-world:linux&quot; in 9.661065021s
13s         Normal    Created             pod/helloworld-656898b9bb-sg6fs    Created container hello-world
13s         Normal    Started             pod/helloworld-656898b9bb-sg6fs    Started container hello-world
13s         Normal    Pulled              pod/helloworld-656898b9bb-sg6fs    Container image &quot;hello-world:linux&quot; already present on machine
11s         Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
24s         Normal    Scheduled           pod/helloworld-656898b9bb-vhhfm    Successfully assigned default/helloworld-656898b9bb-vhhfm to kind-lab-worker
23s         Normal    Pulling             pod/helloworld-656898b9bb-vhhfm    Pulling image &quot;hello-world:linux&quot;
18s         Normal    Pulled              pod/helloworld-656898b9bb-vhhfm    Successfully pulled image &quot;hello-world:linux&quot; in 5.17232683s
3s          Normal    Created             pod/helloworld-656898b9bb-vhhfm    Created container hello-world
2s          Normal    Started             pod/helloworld-656898b9bb-vhhfm    Started container hello-world
3s          Normal    Pulled              pod/helloworld-656898b9bb-vhhfm    Container image &quot;hello-world:linux&quot; already present on machine
2s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
24s         Normal    SuccessfulCreate    replicaset/helloworld-656898b9bb   Created pod: helloworld-656898b9bb-vhhfm
24s         Normal    SuccessfulCreate    replicaset/helloworld-656898b9bb   Created pod: helloworld-656898b9bb-sg6fs
24s         Normal    SuccessfulCreate    replicaset/helloworld-656898b9bb   Created pod: helloworld-656898b9bb-98vrv
24s         Normal    ScalingReplicaSet   deployment/helloworld              Scaled up replica set helloworld-656898b9bb to 3
79s         Normal    Killing             pod/nginx                          Stopping container nginx
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Normal    Pulled              pod/helloworld-656898b9bb-sg6fs    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Created             pod/helloworld-656898b9bb-sg6fs    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-sg6fs    Started container hello-world
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
0s          Normal    Pulled              pod/helloworld-656898b9bb-vhhfm    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Pulled              pod/helloworld-656898b9bb-98vrv    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Created             pod/helloworld-656898b9bb-vhhfm    Created container hello-world
1s          Normal    Created             pod/helloworld-656898b9bb-98vrv    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-vhhfm    Started container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-98vrv    Started container hello-world
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
0s          Normal    Pulled              pod/helloworld-656898b9bb-sg6fs    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Created             pod/helloworld-656898b9bb-sg6fs    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-sg6fs    Started container hello-world
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Normal    Pulled              pod/helloworld-656898b9bb-vhhfm    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Created             pod/helloworld-656898b9bb-vhhfm    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-vhhfm    Started container hello-world
0s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
0s          Normal    Pulled              pod/helloworld-656898b9bb-98vrv    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Created             pod/helloworld-656898b9bb-98vrv    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-98vrv    Started container hello-world
0s          Warning   BackOff             pod/helloworld-656898b9bb-98vrv    Back-off restarting failed container
0s          Warning   BackOff             pod/helloworld-656898b9bb-vhhfm    Back-off restarting failed container
0s          Normal    Pulled              pod/helloworld-656898b9bb-sg6fs    Container image &quot;hello-world:linux&quot; already present on machine
0s          Normal    Created             pod/helloworld-656898b9bb-sg6fs    Created container hello-world
0s          Normal    Started             pod/helloworld-656898b9bb-sg6fs    Started container hello-world
0s          Warning   BackOff             pod/helloworld-656898b9bb-sg6fs    Back-off restarting failed container
</code></pre>

Chen Zhao
<p><code>hello-world</code> image is not a long-running process: it just outputs text and stops.</p>
<p>Kubernetes Pod is by default expecting long-running processes, and if it stops it automatically restart the container.</p>
<p>This behavior is defined by the <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy" rel="nofollow noreferrer"><code>restartPolicy</code> parameter of a pod</a> and can have different values:</p>
<ul>
<li><code>Always</code>: always restart stopped container (the default)</li>
<li><code>OnFailure</code>: restart containers that exited with !=0</li>
<li><code>Never</code>: don't restart containers</li>
</ul>
<p>So in your case you should use one of the 2 last as the container is expected to stop normally.</p>
