I often get this error but I am unable to find the exact reason. Can someone help

Defaulted container “nginx-php-container” out of: nginx-php-container, mysql-container error i get in kubernetes

This error is too often for me and I am unable to fix it. Can someone please let me know, how and where to fix this please. I checked all the indentation etc but doesn’t work. It works randomly sometimes. But I want to know, source of the error and how to quickly fix it.

Is this for a specific lab? If so, please supply me a link to it, so we can check what’s up with this.

This is for 7.Kubernetes LEMP Setup in Level 3 Kubernetes at KodeKloud Engineer | Real Project Tasks on Real Systems.
But at first it worked well but later I always get this error. Also, in some other labs, when I build multicontainer pod or deployment, I often get this error. But, I am not sure, how to fix it quickly.

During my CKA exam last month, I got this error and I couldn’t fix it. I passed the exam as other questions were correct, but I would like to know, how to fix it in any scenario.

Thank you.

This is not an error message.

If you are using kubectl logs, kubectl cp or kubectl exec with a multi container pod, you must tell it which container you want to send the command to, or it will just pick one which might not necessarily be the one you want.

You must use the -c argument to specify the container you want to send the command to, e.g.

kubectl logs -c mysql-container pod-name

if you wanted logs of mysql-container