Home > Blockchain >  Running a shell from within a docker container succeeds but not as an entrypoint ("no such file
Running a shell from within a docker container succeeds but not as an entrypoint ("no such file

Time:09-29

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:

# 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?

CodePudding user response:

Change the entrypoint to:

ENTRYPOINT ["/bin/bash", "-c", "/var/lib/test/test.sh"]
  • Related