【问题标题】:starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory":启动容器进程导致“exec:\”/bin/sh\“:stat /bin/sh:没有这样的文件或目录”:
【发布时间】:2020-06-02 09:43:45
【问题描述】:

我正在尝试从 SCRATCH 在 centos 7 上构建 docker 映像。我已经执行了以下步骤:

FROM scratch
RUN rpm -ivh https://address/app.rpm
RUN YUM install tools 
...
...
CMD ["rpm","start"]

执行此操作后,我尝试使用命令构建此 dockerfile “docker build -t testid -f ./dockerfile .”

现在我看到以下错误:

Sending build context to Docker daemon  3.072kB
Step 1/16 : FROM scratch
 --->
Step 2/16 : RUN rpm -ivh https://address/app.rpm
 ---> Running in d25a0a879d9e
OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown

请让我知道是否有人对此有建议。 ?

任何意见都会很有帮助。

谢谢。

【问题讨论】:

    标签: docker dockerfile containers docker-image docker-command


    【解决方案1】:

    FROM scratch 从一个完全空的图像开始。容器文件系统中唯一的内容是 Docker 自动提供的 /dev/proc/etc 中的文件。当您说rpm 时,该命令不存在。一个字符串形式的RUN 命令被包装在/bin/sh -c ... 中,但没有/bin 目录。

    FROM scratch 是 Docker 的一种高级用法。如果您对静态链接二进制文件等概念以及裸字符串和 JSON 数组 CMD 之间的区别非常熟悉,则可以使用它来制作非常小的图像。对于大多数典型用途,您至少需要从某种分发和包管理器开始。

    如果你需要 Red Hat 的包管理工具,最简单的 Docker Hub 镜像是centos

    FROM centos:8 # includes rpm, yum, /bin directory
    RUN rpm -ivh https://address/app.rpm
    RUN yum install tools
    ...
    

    【讨论】:

    • 感谢@David Maze 的帮助。
    猜你喜欢
    • 2019-07-16
    • 1970-01-01
    • 2021-09-17
    • 2015-06-14
    • 2019-03-17
    • 2023-02-06
    • 2019-12-10
    • 1970-01-01
    • 2020-10-09
    相关资源
    最近更新 更多