Docker entrypoint not found although in PATH (and executable)

pkaramol picture pkaramol · Jul 26, 2018 · Viewed 8.3k times · Source

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);

Answer

joelnb picture joelnb · Jul 26, 2018

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).