<p>Since Kubernetes 1.25, the <a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container" rel="nofollow noreferrer">ephemeral containers</a> are stable.</p>
<p>I can inject ephemeral container into running pod but when the purpose of debug container ends I'd like to remove the container from the pod but I still see it with Terminated state.</p>
<p>The docs currently say to delete the container I must delete whole pod similar to copied pod but I don't think that is right.</p>
<p>How can I delete ephemeral container from running pod without destroying it?</p>

<p>Unfortunately it isn't possible to do what you say.</p>
<blockquote>
<p>Ephemeral containers are created using a special <em>ephemeralcontainers</em> handler in the API rather than by adding them directly to <em>pod.spec</em>, so it's not possible to add an ephemeral container using <em>kubectl edit</em>.</p>
</blockquote>
<blockquote>
<p>Like regular containers, you may not change or remove an ephemeral container after you have added it to a Pod.</p>
</blockquote>
<p><a href="https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/#understanding-ephemeral-containers" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/#understanding-ephemeral-containers</a></p>
