pkaramol
pkaramol

Reputation: 19342

Docker entrypoint not found although in PATH (and executable)

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

Upvotes: 8

Views: 20623

Answers (3)

Mohit
Mohit

Reputation: 311

I face the same issue and the reason i found on another stack over flow answer is line encoding difference, I got my docker file from one of open source project, and I building and deploying my file on Docker Desktop for Winodw, I changed my Docker & .sh file encoding from CRLF -> LF and it worked, you can use VS code for same it have bootom right corner option to convert CRLF to LF.

Upvotes: 1

Bob
Bob

Reputation: 6173

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.

Upvotes: 3

joelnb
joelnb

Reputation: 1494

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

Upvotes: 13

Related Questions