5-15|Docker报错OCI runtime exec failed: exec failed: unable to start container process: exec: “/bin/ba

简介: 5-15|Docker报错OCI runtime exec failed: exec failed: unable to start container process: exec: “/bin/ba

Docker报错OCI runtime exec failed: exec failed: unable to start container process: exec: “/bin/bash“解决

报错

进入容器时,报如下错误:

[root@iZhp33j6fklnmhbf0lz2obZ admin]# docker exec -it admin_web_1 /bin/bash

OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown

解决

将 /bin/bash换成 /bin/sh成功

[root@iZhp33j6fklnmhbf0lz2obZ admin]# docker exec -it admin_web_1 /bin/sh

/code # ls

Dockerfile          app.py              bak                 docker-compose.yml  index.html

分析

制作镜像时使用了精简版,只装了sh命令,未安装bash。

如下都是精简版:

redis:alpine FROM

python:3.6-alpine

小拓展

Shell简介

Shell是一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务。Shell 是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁。Shell 既是一种命令语言,又是一种程序设计语言。

sh(Bourne Shell)是一个早期的重要shell,1978年由史蒂夫·伯恩编写,并同Version 7 Unix一起发布。

bash(Bourne-Again Shell)是一个为GNU计划编写的Unix shell。1987年由布莱恩·福克斯创造。主要目标是与POSIX标准保持一致,同时兼顾对sh的兼容,是各种Linux发行版标准配置的Shell,在Linux系统上/bin/sh往往是指向/bin/bash的符号链接。

含义:

#! 是一个特殊标记,说明这是一个可执行的脚本。除了第一行,其他以#开头的都不再生效,为注释。

#! 后面是脚本的解释器程序路径。这个程序可以是shell,程序语言或者其他通用程序,常用的是bash、sh。

#!/bin/bash

#!/bin/sh

查看

查看系统可使用的shell类型

cat /etc/shells    

[root@iZhp33j6fklnmhbf0lz2obZ admin]#  cat /etc/shells

/bin/sh

/bin/bash

/usr/bin/sh

/usr/bin/bash

查看当前默认设置,一般在第一行

cat /etc/passwd    

[root@iZhp33j6fklnmhbf0lz2obZ admin]# cat /etc/passwd

root:x:0:0:root:/root:/bin/bash

查看当前sh状态

ll /bin/sh  

查看当前bash状态

ll /bin/bash  

[root@iZhp33j6fklnmhbf0lz2obZ admin]# ll /bin/sh

lrwxrwxrwx. 1 root root 4 Nov  9  2019 /bin/sh -> bash

[root@iZhp33j6fklnmhbf0lz2obZ admin]# ll /bin/bash

-rwxr-xr-x. 1 root root 1219248 Nov  9  2019 /bin/bash


相关文章
|
9月前
|
Ubuntu Linux Shell
(已解决)Linux环境—bash: wget: command not found; Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
(已成功解决)Linux环境报错—bash: wget: command not found;常见Linux发行版本,Linux中yum、rpm、apt-get、wget的区别;Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
4294 69
(已解决)Linux环境—bash: wget: command not found; Docker pull报错Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled
|
7月前
|
Linux Docker 容器
安装docker-18.06报错Error: libseccomp conflicts with docker-18.06
通过这些步骤,您可以成功在CentOS上安装Docker 18.06,并解决libseccomp的冲突问题。这些方法确保系统兼容性,并保证Docker的正常运行。
204 27
|
11月前
|
JavaScript 前端开发 Docker
拿下奇怪的前端报错(二):nvm不可用报错`GLIBC_2.27‘‘GLIBCXX_3.4.20‘not Found?+ 使用docker构建多个前端项目实践
本文介绍了在多版本Node.js环境中使用nvm进行版本管理和遇到的问题,以及通过Docker化构建流程来解决兼容性问题的方法。文中详细描述了构建Docker镜像、启动临时容器复制构建产物的具体步骤,有效解决了不同项目对Node.js版本的不同需求。
468 1
|
2月前
|
存储 监控 测试技术
如何将现有的应用程序迁移到Docker容器中?
如何将现有的应用程序迁移到Docker容器中?
236 57
|
3月前
|
存储 运维 安全
Docker化运维:容器部署的实践指南
Docker化运维:容器部署的实践指南
|
2月前
|
存储 监控 Java
如何对迁移到Docker容器中的应用进行性能优化?
如何对迁移到Docker容器中的应用进行性能优化?
231 58
|
2月前
|
NoSQL Redis Docker
使用Docker Compose工具进行容器编排的教程
以上就是使用Docker Compose进行容器编排的基础操作。这能帮你更有效地在本地或者在服务器上部署和管理多容器应用。
294 11
|
2月前
|
缓存 Java Docker
如何对应用代码进行优化以提高在Docker容器中的性能?
如何对应用代码进行优化以提高在Docker容器中的性能?
195 1
|
3月前
|
Docker 容器
Docker网关冲突导致容器启动网络异常解决方案
当执行`docker-compose up`命令时,服务器网络可能因Docker创建新网桥导致IP段冲突而中断。原因是Docker默认的docker0网卡(172.17.0.1/16)与宿主机网络地址段重叠,引发路由异常。解决方法为修改docker0地址段,通过配置`/etc/docker/daemon.json`调整为非冲突段(如192.168.200.1/24),并重启服务。同时,在`docker-compose.yml`中指定网络模式为`bridge`,最后通过检查docker0地址、网络接口列表及测试容器启动验证修复效果。