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

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

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

It’s look like this:

 FROM ubuntu:16.04

 MAINTAINER user <user@mail.com>

# 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 http://download.oracle.com/otn-pub/java/jdk/8u171- 
b11/512cd62ec5174c3487ac17c61aaa89e8/$filename

# 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
ENV PATH $JAVA_HOME/bin:$PATH

# 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 my_script.sh
CMD ["my_script.sh","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: "/my_script.sh": stat /my_script.sh: no such file or directory”: unknown.

Any solution for this error?
Thank you.

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", "my_script.sh", "run"] – interpreters usually look up the script from the current working directory)

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

i have the same issue:
cker run -it flexdock
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec:

i and there is my Dockerfile:
FROM yobasystems/alpine:3.8-amd64
LABEL maintainer “flextest>” architecture=“AMD64/x86_64” date=“15-01-2019”
ENV LANG en_GB.utf8
ENV PGDATA /var/lib/postgresql/data

RUN apk update &&
apk add su-exec tzdata libpq postgresql-client postgresql postgresql-contrib &&
mkdir /docker-entrypoint-initdb.d &&
rm -rf /var/cache/apk/*

VOLUME /var/lib/postgresql/data

COPY docker-entrypoint.sh /path
RUN ln -s path/docker-entrypoint.sh /
ENTRYPOINT ["/path/docker-entrypoint.sh"]

EXPOSE 5432
CMD [“postgres”]