Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.2K
Views
The command '/bin/sh returned a non-zero code: 1

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

./MyBinfile.bin

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

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?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

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

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

EDIT

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

then it executes OK.

over 4 years ago · Santiago Trujillo Report

0

I had a close similar issue when running NextJs inside Docker. Here is how I solved the issue::

Note:: This solution will also solve the EACCES error...Permission denied when accessing files inside the dockerized app e.g. route pages.

I added root user immediately before the command to change ownership then later switched back to run the rest of the commands together with container with non-root user i.e. node user from base alpine image.

# The "./" is the working directory e.g. /usr/app
USER root
RUN chmod a+w ./ -R

# Later switch back to run rest of commands and container as node non-root user 
USER node
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!