Docker Community Forums

Share and learn in the Docker community.

Starting container process caused "exec: \"my_script\": stat /my_script: executable file not found in $PATH": unknown


(Marwenb) #1

Hi every one,
I’m working on put and run my_script in a docker container using Dockerfile,

At first i applied “chmod +x” in “myfolder” before i add it in the container.

It’s look like this:

 FROM ubuntu:16.04


# update dpkg repositories
RUN apt-get update \
     && mkdir -p  /root/docker

 RUN apt-get install -y wget

 ADD myfolder /root/docker/mydolder

 WORKDIR /root/docker/myfolder/bin

# set shell variables for java installation
ENV java_version 1.8.0_171
ENV filename jdk-8u171-linux-x64.tar.gz
ENV downloadlink 

# download java, accepting the license agreement
RUN wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" -O /tmp/$filename $downloadlink 

 # unpack java
RUN mkdir /opt/java-oracle && tar -zxf /tmp/$filename -C /opt/java-oracle/
ENV JAVA_HOME /opt/java-oracle/jdk$java_version

# configure symbolic links for the java and javac executables
RUN update-alternatives --install /usr/bin/java java $JAVA_HOME/bin/java 20000 \
     && update-alternatives --install /usr/bin/javac javac $JAVA_HOME/bin/javac 20000

RUN chmod +x
CMD ["","run"]

The build passed successfully but when i’m trying to run ,

docker run --name my_script -d my_script

I got this error:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused “exec: “/”: stat / no such file or directory”: unknown.

Any solution for this error?
Thank you.

(Tnelis) #2

I believe the engine searches for executables in PATH and the root only.

Any of these approaches should work:

  • Place your script in PATH
  • Place your script at the root
  • Add your myfolder directory to the PATH
  • Specify the interpreter explicitly (instead of leveraging the shebang, set the command to ["sh", "", "run"] – interpreters usually look up the script from the current working directory)

(Marwenb) #3

Thank you for your response,
Yes now it works fine Now.