<p>I created a deployment in which the container always fails, I noticed a new container is automatically created because of the restart policy, but then I am unable to check the log of the failed container. Is there a way to check the log?</p>

Dagang
<p>You can use the <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#logs" rel="nofollow noreferrer"><code>kubectl logs --previous</code></a> flag:</p>

<blockquote>
  <p><strong>--previous</strong> <em>If true, print the logs for the previous instance of the container in a pod if it exists.</em></p>
</blockquote>

<p>Example:</p>

<pre><code>kubectl logs my-pod-crashlooping --container my-container --previous
</code></pre>
