OpenShift - Resolve "error: unable to upgrade connection: container not found"

by
Jeremy Canfield |
Updated: November 16 2022
| OpenShift articles
Let's say you are attempting to use the oc exec command to run a command in a container in a pod.
oc exec pod/my-pod-78f97cfd6d-dptdq -c my-container -- df
And the following is being returned.
error: unable to upgrade connection: container not found ("my-container")
I typically find that there is some issue causing the pod to be restart over and over and over again. In this scenario, you of course would want to determine why the pod keeps restarted over and over again. Check out my article on resolving CrashLoopBackOff.
~]$ oc get pods
NAME READY STATUS RESTARTS AGE
my-pod-78f97cfd6d-dptdq 0/1 CrashLoopBackOff 8260 (5m23s ago) 19d
Did you find this article helpful?
If so, consider buying me a coffee over at