Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Running a shell from within a docker container succeeds but not as an entrypoint ("no such file or directory" error)

I made a small container that runs a single shell script.
Its Dockerfile is as follows:

FROM centos:centos7.9.2009

RUN mkdir -p /var/lib/test
COPY ./ /var/lib/test/
RUN yum -y localinstall /var/lib/test/*.rpm

ENTRYPOINT ["sh /var/lib/test/test.sh"]

However, when I run the image, it returns the error:

#docker run -it test:1.0
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:290: starting container process caused "exec: \"sh /var/lib/test/test.sh\": stat sh /var/lib/test/test.sh: no such file or directory".

The script file definitely exists as I can replace its entrypoint with bash and manually execute it:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

# docker run -it --entrypoint bash test:1.0
[root@e9361c3e67fa /]# sh /var/lib/test/test.sh
Shell script starts...

I read similar posts and confirmed that the permission of the script is correct, the return codes inside it were all LF.

And the shell script is really simple:

#!/bin/bash
echo "Test"
exit 0

What else can cause this problem?

>Solution :

Change the entrypoint to:

ENTRYPOINT ["/bin/bash", "-c", "/var/lib/test/test.sh"]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading