启动容器过程导致“ exec:\ / bin / sh\”:stat / bin / sh:没有此类文件或目录”:未知 [英] Starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown

查看:2437
本文介绍了启动容器过程导致“ exec:\ / bin / sh\”:stat / bin / sh:没有此类文件或目录”:未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解CMD和ENTRYPOINT的工作原理。因此,我刚刚创建了一个非常简单的 Dockerfile

I want to understand how CMD and ENTRYPOINT works. So, I just created a very simple Dockerfile

FROM scratch

CMD echo "Hello First"

ENTRYPOINT echo "Hello second" 

然后我构建此映像:

docker build -t my_image .

日志如下:


步骤1/3:从头开始--->步骤2/3:CMD回显 Hello First --->
使用缓存---> 9f2b6a00982f步骤3/3:ENTRYPOINT echo Hello
second --->使用缓存---> 1bbe520f9526成功构建
1bbe520f9526成功标记my_image:latest安全警告:您
正在Windows上针对非Windows操作系统构建Docker映像-Windows Docker
主机。添加到构建上下文的所有文件和目录都将具有
的-rwxr-xr-x权限。建议仔细检查并重置敏感文件和目录的
权限。

Step 1/3 : FROM scratch ---> Step 2/3 : CMD echo "Hello First" ---> Using cache ---> 9f2b6a00982f Step 3/3 : ENTRYPOINT echo "Hello second" ---> Using cache ---> 1bbe520f9526 Successfully built 1bbe520f9526 Successfully tagged my_image:latest SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context w ill have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.

当我创建此图像的容器时它会返回:

When I create a container of this image it returns:

docker run my_image

错误是:


docker:来自守护程序的错误响应:OCI运行时创建失败:
container_linux.go:344:启动容器进程导致 exec:
\ / bin / sh\:stat / b in / sh:无此类文件或目录:未知。

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/bin/sh\": stat /b in/sh: no such file or directory": unknown.

有人可以帮助我解决错误吗?

Can someone please help me about error?

推荐答案

这里发生两件事。

FROM从头开始的Dockerfile从基本没有任何内容的基础映像开始在其中。它完全是空的。除了Docker为您提供的一些设备文件外,没有一组基础工具或库或其他任何东西。

A Dockerfile that starts FROM scratch starts from a base image that has absolutely nothing at all in it. It is totally empty. There is not a set of base tools or libraries or anything else, beyond a couple of device files Docker pushes in for you.

ENTRYPOINT回显... 命令被Docker重写为 ENTRYPOINT [ / bin / sh, -c, echo ...] ,并使 CMD 被完全忽略。除非被 docker run --entrypoint 覆盖,否则它将成为容器运行的主要过程。

The ENTRYPOINT echo ... command gets rewritten by Docker into ENTRYPOINT ["/bin/sh", "-c", "echo ..."], and causes the CMD to be totally ignored. Unless overridden with docker run --entrypoint, this becomes the main process the container runs.

因为它是一个 FROM暂存器映像,根本不包含任何内容,它不包含外壳程序,因此出现 / bin / sh:无此类文件或目录错误。

Since it is a FROM scratch image and contains absolutely nothing at all, it doesn't contain a shell, hence the "/bin/sh: no such file or directory" error.

这篇关于启动容器过程导致“ exec:\ / bin / sh\”:stat / bin / sh:没有此类文件或目录”:未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆