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

简介: 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
目录
相关文章
|
2月前
|
移动开发 Shell Linux
百度搜索:蓝易云【Shell错误:/bin/bash^M: bad interpreter: No such file or directory】
将 `your_script.sh`替换为你的脚本文件名。运行此命令后,脚本文件的换行符将被转换为Linux格式,然后就可以在Linux系统上正常执行脚本了。
48 8
|
2月前
|
Java Shell Linux
解决 centos下执行sh文件报错“/bin/bash^M: 坏的解释器:没有那个文件或目录” 问题
解决 centos下执行sh文件报错“/bin/bash^M: 坏的解释器:没有那个文件或目录” 问题
289 0
|
1月前
|
关系型数据库 MySQL Shell
进入mysql报错:bash:/bin/mysql:没有那个文件或目录
进入mysql报错:bash:/bin/mysql:没有那个文件或目录
23 4
|
2月前
|
Unix Shell iOS开发
Shell错误:/bin/bash^M: bad interpreter: No such file or directory
Shell错误:/bin/bash^M: bad interpreter: No such file or directory
52 0
|
8月前
|
Ubuntu Shell
bash: No such file or directory
bash: No such file or directory
102 0
|
2月前
|
监控 安全 Shell
防止员工泄密的措施:在Linux环境下使用Bash脚本实现日志监控
在Linux环境下,为防止员工泄密,本文提出使用Bash脚本进行日志监控。脚本会定期检查系统日志文件,搜索敏感关键词(如"password"、"confidential"、"secret"),并将匹配项记录到临时日志文件。当检测到可疑活动时,脚本通过curl自动将数据POST到公司内部网站进行分析处理,增强信息安全防护。
148 0
|
2月前
|
Linux Shell Windows
4:Bash shell命令-步入Linux的现代方法
4:Bash shell命令-步入Linux的现代方法
64 0
|
11月前
|
Ubuntu 安全 Linux
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
不用安装虚拟机,直接在Windows上面运行Linux Bash Shell,嗯!真香!!!
195 0
|
9月前
|
关系型数据库 MySQL Shell
【Linux命令】-bash: mysql: command not found
【Linux命令】-bash: mysql: command not found
65 0
|
2月前
|
存储 Shell Linux
Linux Bash 脚本中的 IFS 是什么?
【4月更文挑战第25天】
48 0
Linux Bash 脚本中的 IFS 是什么?