Kubernetes container throwing exit code 2

Hey team, I am facing issue where one of the pod is going on crashloopbackoff. upon running pod describe command I can see the container is throwing exit code 2. I am not sure what is the reason and how to fix this. your help is greatly appreciated.

The return code comes from the container’s process as it exits, and as such, it depends upon what process was running. That’s different for different containers. So, what’s the container and what’s it running? If it’s a program you have documentation for or the code for, you’d need to analyze that program.

Code 2 is ENOENT (error no entity) which means something made a request for a file or directory that does not exist, assuming the application is returning the last unix error code it received.
You would definitely get this if the command to run under command: is not found.

Getting logs from the container might help.

OK, had to look that up; errno -l give you. a list. But in bash, the code of 2 has the alternate meaning of Misuse of shell builtins (according to Bash documentation). Because in technology and software, the best thing about standards is there is so many to choose from.

Either way the answer should be in the pod logs

  • Misuse of shell built-in - bash will definitely have output something that will be logged
  • Application itself returned error 2 - If the app is doing proper logging, it will be in the logs, else you need to debug the app (or get its developer to do so).