命令'/ bin / sh返回了非零代码:1 [英] The command '/bin/sh returned a non-zero code: 1

查看:374
本文介绍了命令'/ bin / sh返回了非零代码:1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在ubuntu Docker容器中手动安装bin文件时,它运行良好。

When I try to install a bin file manually inside a ubuntu Docker container it works perfectly,

./MyBinfile.bin

但是当我从Dockerfile中尝试它时,总是出现错误:
命令' / bin / sh -c chmod + x /tmp/snapcenter_linux_host_plugin.bin&& ./tmp/MyBinFile.bin'返回了一个非零代码:1

but when I try it from my Dockerfile I always get the error : The command '/bin/sh -c chmod +x /tmp/snapcenter_linux_host_plugin.bin && ./tmp/MyBinFile.bin' returned a non-zero code: 1

我的Dockerfile如下:

My Dockerfile looks like :

    FROM debian:jessie

    RUN apt-get update && apt-get install -y openjdk-7-jdk
    ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
    RUN echo $JAVA_HOME

    COPY MyBinFile.bin /tmp/MyBinFile.bin
    RUN chmod +x /tmp/MyBinFile.bin && ./tmp/MyBinFile.bin

在这种情况下有人可以帮助我吗?

Can anyone help me in this case?

推荐答案

您将MyBinFile.bin复制到了/tmp/MyBinFile.bin。这些不是同一文件。如果您需要运行它,请为其上具有可执行文件属性的文件使用绝对路径。因此,您的最后一行应该是:

You copied MyBinFile.bin to /tmp/MyBinFile.bin. Those are not the same file. If you need to run it use absolute path for the file that has executable attribute on it. So your last line should be:

RUN chmod +x /tmp/MyBinFile.bin && /tmp/MyBinFile.bin

’。(点)表示您当前的当前工作目录。建议您始终使用绝对路径,如果不确定您的cwd是什么。

'.' (dot) represents your current current working directory. It's recommended to always use absolute paths if you're unsure what is your cwd.

EDIT

运行Dockerfile会产生以下输出:

Running your Dockerfile produces the following output:

Sending build context to Docker daemon 3.584 kB
Step 1/6 : FROM debian:jessie
 ---> 8cedef9d7368
Step 2/6 : RUN apt-get update && apt-get install -y openjdk-7-jdk
 ---> Using cache
 ---> 1a0005923f41
Step 3/6 : ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
 ---> Using cache
 ---> 5651d50b519e
Step 4/6 : RUN echo $JAVA_HOME
 ---> Using cache
 ---> 96655235a2cf
Step 5/6 : COPY MyBinFile.bin /tmp/MyBinFile.bin
 ---> 60c79aaf5aca
Removing intermediate container cd729c315e9b
Step 6/6 : RUN chmod +x /tmp/MyBinFile.bin && /tmp/MyBinFile.bin
 ---> Running in 5db126cbd24c
/bin/sh: 1: /tmp/MyBinFile.bin: Text file busy
The command '/bin/sh -c chmod +x /tmp/MyBinFile.bin && 
/tmp/MyBinFile.bin' returned a non-zero code: 2

但是我将您的最后一步分为两个不同的步骤:

But if I separate your last step into two different steps:

FROM debian:jessie

RUN apt-get update && apt-get install -y openjdk-7-jdk
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
RUN echo $JAVA_HOME

COPY MyBinFile.bin /tmp/MyBinFile.bin
RUN chmod +x /tmp/MyBinFile.bin
RUN /tmp/MyBinFile.bin

然后执行OK。

这篇关于命令'/ bin / sh返回了非零代码:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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