Docker entrypoint not found although in PATH (and executable)
Solution 1
Interestingly your issues seems to be with the type of quotes you have chosen to use. If you change this line:
ENTRYPOINT ['docker-entrypoint.sh']
to
ENTRYPOINT ["docker-entrypoint.sh"]
then everything starts to work as expected.
If you check the documentation for the type of ENTRYPOINT
you are using all of the examples have double quotes.
I suspect what is happening when you use the single quotes is that docker is parsing this as the shell form of ENTRYPOINT
and trying to execute a script called [docker-entrypoint.sh]
which would explain the error message (as obviously no script of that name will exist).
Solution 2
I was getting exactly the same error under the same circumstances (although no single quotes problem) when the docker-entrypoint.sh
script contained carriage returns, converting the script with dos2unix docker-entrypoint.sh
fixed the issue for me.
pkaramol
Updated on August 02, 2022Comments
-
pkaramol over 1 year
I am creating a simple image with the following
Dockerfile
FROM docker:latest COPY docker-entrypoint.sh /usr/local/bin ENTRYPOINT ['docker-entrypoint.sh']
Inside my container:
/ # ls -al $(which docker-entrypoint.sh) -rwxrwxr-- 1 root root 476 Jul 26 07:30 /usr/local/bin/docker-entrypoint.sh
So the entrypoint file is both in the
PATH
and executable;But when running
docker run -v /var/run/docker.sock:/var/run/docker.sock -it imageinit /bin/sh: [docker-entrypoint.sh]: not found
I am aware of this SO question, but this is about the problem of
PATH
and file permissions (already addressed); -
bunji over 4 yearsExtra detail: In the documentation you link to it mentions that the reason for double quotes is because docker parses the value as a json array.
-
joelnb over 4 yearsThanks for the extra info! This made me think about why when it uses single quotes they are not printed in the error. As I found the answer I though I would share in case it's interesting to anyone else. When docker finds an ENTRYPOINT command it uses parseEntrypoint which calls parseShellDependentCommand in the same file. This then checks if the command was valid JSON & if not, prepends the shell to the command. So it actually runs
/bin/sh ['docker-entrypoint.sh']
and the shell swallows the quotes -
Dan Garland over 2 yearsIt's stuff like this that make me wanna quit tech!