Welcome to the Linux Foundation Forum!

Error in the Lab 10.1: "error: unable to upgrade connection: container not found ("ngix")"


When I did the step 11, I found the pod "thirdpage-77c4bc9757-bwbpx" not running. And then I finished step 12 and 13. When I tried to do step 14 , I got an error "error: unable to upgrade connection: container not found ("ngix")". Could you please help me to figure out this?



student@master:~$ kubectl create deployment thirdpage --image=ngix
deployment.apps/thirdpage created
student@master:~$ kubectl get po
secondapp-5cf87c9f48-cxtj2 1/1 Running 0 20h
thirdpage-77c4bc9757-bwbpx 0/1 ImagePullBackOff 0 14s

student@master:~$ kubectl expose deployment thirdpage --type=NodePort --port=80
service/thirdpage exposed
student@master:~$ kubectl get svc
kubernetes ClusterIP 443/TCP 5d4h
secondapp NodePort 80:32497/TCP 20h
thirdpage NodePort 80:32023/TCP 4s

student@master:~$ kubectl exec -it thirdpage-77c4bc9757-bwbpx -- /bin/bash
error: unable to upgrade connection: container not found ("ngix")

Best Answer


  • zhangwe
    zhangwe Posts: 45

    Yes, my image name is not right. Thank you very much for your help.

  • krunallathiya

    The error message "error: unable to upgrade connection: container not found ("ngix")" that you are encountering in Kubernetes typically indicates that there's an issue with the container name specified in your command. It seems like there might be a typo in the container name.

    In Kubernetes, when you execute a command like kubectl exec to enter a container, you need to specify the exact name of the container if the pod has multiple containers. The error suggests that Kubernetes cannot find a container named "ngix" in the specified pod. This name seems like it's intended to be "nginx", the name of a popular web server.

    Here’s how you can troubleshoot and potentially resolve this issue:

    1. Check the Pod's Container Names
      First, verify the name of the container inside the pod. You can list all containers in a pod using the following command:

    kubectl get pod thirdpage-77c4bc9757-bwbpx -o jsonpath='{.spec.containers[*].name}'

    1. Correct the Container Name
      Use the correct container name in your kubectl exec command. If the container is indeed named "nginx", the command should look something like this:

    kubectl exec -it thirdpage-77c4bc9757-bwbpx -c nginx -- /bin/bash

    1. Check the Pod Status

    Since you mentioned the pod "thirdpage-77c4bc9757-bwbpx" was not running, ensure that the pod is in a running state. You can check the status of the pod with:

    kubectl get pod thirdpage-77c4bc9757-bwbpx


Upcoming Training