Command '/ bin / sh returned non-zero code: 1

When I try to install the bin file manually inside the ubuntu Docker container it works fine,

./MyBinfile.bin

      

but when I try to execute it from my Dockerfile I always get the error: Command '/ bin / sh -c chmod + x / tmp / snapcenter_linux_host_plugin.bin && & & &. / tmp / MyBinFile.bin' returns non-zero code: 1

My Dockerfile looks like this:

    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?

+3


source to share


1 answer


You have copied MyBinFile.bin to /tmp/MyBinFile.bin. This is not the same file. If you need to run it, use the absolute path for the file that contains the executable attribute. So, your last line should be:

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

      

'' (period) represents the current current working directory. He recommends to always use absolute paths unless you know what your cwd is.

EDIT

Running your Dockerfile results in 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

      

then it will execute OK.

+1


source







All Articles