starting container process caused “exec: \“/bin/bash\“: stat /bin/bash: no such file or directory

一、问题内容

登录到K8S单个部署的容器中时,登出虚线报错。

kubectl -n prod mytest -it test-web  /bin/bash

完整报错信息

[root@lydtest01 ~]$ kubectl -n prod mytest -it test-web  /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
OCI runtime exec failed: exec failed: container_linux.go:348: 
starting container process caused 
"exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
command terminated with exit code 126
[root@lydtest01 ~]# 

二、问题原因

最核心内容,没有找到/bin/bash这个执行文件,代表服务器没有安装bash脚本

"/bin/bash\": stat /bin/bash: no such file or directory

一般的容器都可以执行/bin/bash,但也有部分容器没有,那么我们可以用/bin/sh来替换/bin/bash

三、解决问题

bash登录方式,更换为sh登录

kubectl -n prod mytest -it test-web  /bin/sh

你可能感兴趣的:(日常Bug,bash,linux,开发语言)