【问题标题】:The command '/bin/sh -c returned a non-zero code: 127命令 '/bin/sh -c 返回一个非零代码:127
【发布时间】:2015-10-30 19:09:26
【问题描述】:

我是 docker 新手,所以我可能做错了,但我正在尝试通过 Dockerfile 安装 Tomcat6,如下所示:

FROM rhel7:latest
RUN cd /tmp
RUN "wget", "http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz"
RUN tar xzf apache-tomcat-6.0.44.tar.gz
RUN mv apache-tomcat-6.0.44 /usr/local/tomcat6
RUN cd /usr/local/tomcat6
Run ./bin/start.sh

它在第三行失败了:

  RUN "wget", "http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz"

当我运行 docker build 时,我得到了这个:

我正在使用:

  • Oracle Virtual Box V4.3.28 r100309
  • RHEL7 上的 Docker

提前感谢您的帮助。

【问题讨论】:

  • 我看到这篇文章是为了寻找 CentOS 7 服务器中 returned a non-zero code: 139 的解决方案。我已经解决了我的问题,只是再次卸载并重新安装 docker。 sudo yum remove docker.x86_64 docker-common.x86_64 docker-distribution.x86_64 docker-rhel-push-plugin.x86_64sudo yum remove docker.x86_64 docker-common.x86_64 docker-distribution.x86_64 docker-rhel-push-plugin.x86_64
  • @WellingtonSouza 错误 139 表示您正在为错误的 CPU 架构进行编译

标签: docker tomcat6 rhel dockerfile rhel7


【解决方案1】:

图片出错的解决方法是在wget CMD RUN yum -y install wget之前添加

这样写,结果是一样的,只是执​​行方式不同:

 RUN wget http://www.us.apache.org/dist/tomcat/tomcat-6/v6.0.44/bin/apache-tomcat-6.0.44.tar.gz

不要在RUN 命令中使用引号和逗号。

【讨论】:

  • 它没有区别,它仍然给出同样的错误
  • 在这种情况下,在抛出错误的行之前添加语句RUN yum -y install wget
  • 谢谢,我已经尝试过了,但它现在以代码 1 退出。这就是显示的内容。 i.imgur.com/wqmlenh.png我有一个 RedHat 订阅,我在机器上使用它,我必须使用 Docker 进行订阅管理登录吗?
  • 我已经有一段时间没有使用 RHEL 映像了。但该消息表明您需要注册 Red Hat Subscription Manager。如果可以的话,我建议您在这方面寻求红帽支持的帮助。
【解决方案2】:

shell 命令的退出代码 127 表示“找不到命令”。因此,在您的情况下,当 Docker 运行它时,似乎找不到引号中的“wget”。

在某些情况下,安装 wget 的命令(或缺少的任何命令行工具)必须首先在 Dockerfile 中运行,因为某些基础 Docker 映像将没有 wget。您可以在失败的命令之前添加一行,如下所示:

RUN yum install -y wget

【讨论】:

    【解决方案3】:

    别忘了你可以在同一行添加所有需要的库和包

    RUN cd /tmp \
    && apt-get update \
    && apt-get install -y curl apt-utils wget unzip\
    && rm -rf /var/lib/apt/lists/*

    【讨论】:

      猜你喜欢
      • 2020-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-05
      • 2019-02-02
      • 2021-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多