<p>When a container restarts in Kubernetes (due to exiting with a non-zero exit status), it will be restarted if unless I specify restartPolicy:never .</p>
<p>Question: will the new container get the same container id, or will it have a different one?
In my tests on KIND (K8s-in-Docker) it seems to get the same container id -- is this guaranteed?</p>
<p>Thanks, all.</p>
<p>Alex</p>

Alejandro703
<p>Both pod and container are ephemeral. If a pod gets recreated it gets a new ID. The same goes with container ID. You can check that in a few steps:</p>
<ul>
<li><p>Create a deployment, for example: <code>kubectl create deployment --image=nginx nginx-app</code></p>
</li>
<li><p>list the pods to see if the freshly created one is up and running: <code>kubectl get pods</code></p>
</li>
<li><p>see the container details of that pod with: <code>kubectl describe pod nginx-app-&lt;pod_id&gt;</code>, you can find the Container ID in section <code>Containers:</code></p>
</li>
<li><p>delete the pod with <code>kubectl delete pod nginx-app-&lt;pod_id&gt;</code> so the deployment can start another one in his place</p>
</li>
<li><p>again see the details of the new nginx-app pod with <code>kubectl describe pod nginx-app-&lt;new_pod_id&gt;</code> and notice that it has a different Container ID</p>
</li>
</ul>
