<p>I have a running k8s cluster with two replicas of CoreDNS. But when i try enter the bash prompt of the POD it's throwing me below error</p>
<pre><code># kubectl exec -it coredns-5644d7b6d9-285bj -n kube-system sh
error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec &quot;94f45da89fa5493a8283888464623788ef5e832dc31e0d89e427e71d86391fd6&quot;: OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused &quot;exec: \&quot;sh\&quot;: executable file not found in $PATH&quot;: unknown
</code></pre>
<p>But i am able to login to other pods without any issues. I tried with nsenter with kernel process ID it works but it only works for network related openrations like,</p>
<pre><code># nsenter -t 24931 -n ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: eth0@if5: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1400 qdisc noqueue state UP group default
    link/ether 7a:70:99:aa:53:6c brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.0.2/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::7870:99ff:feaa:536c/64 scope link
       valid_lft forever preferred_lft forever
</code></pre>
<p>How to enter into this pod using kubectl and get rid of that error?</p>

Shoaib Mohammed
<p>You can use the sidecar pattern following the instructions here:  <a href="https://support.rancher.com/hc/en-us/articles/360041568712-How-to-troubleshoot-using-the-namespace-of-a-container#sidecar-container-0-2" rel="noreferrer">https://support.rancher.com/hc/en-us/articles/360041568712-How-to-troubleshoot-using-the-namespace-of-a-container#sidecar-container-0-2</a></p>
<p>In short, do this to find a node where a coredns pod is running:</p>
<pre><code>kubectl -n kube-system get po -o wide | grep coredns
</code></pre>
<p>ssh to one of those nodes, then:</p>
<pre><code>docker ps -a | grep coredns
</code></pre>
<p>Copy the Container ID to clipboard and run:</p>
<pre><code>ID=&lt;paste ID here&gt;
docker run -it --net=container:$ID --pid=container:$ID --volumes-from=$ID alpine sh
</code></pre>
<p>You will now be inside the &quot;sidecar&quot; container and can poke around.  I.e.</p>
<pre><code>cat /etc/coredns/Corefile
</code></pre>
