I was working with a fairly simple Dockerfile, defining an entrypoint and always got a “not found” error when trying to run the container.
Dockerfile looked something like this:
FROM python:3.9-alpine [...] WORKDIR /app COPY . /app RUN ["chmod", "+x", "./entrypoint.sh"] ENTRYPOINT ['./entrypoint.sh']
Building the image worked without issues, but running the container was giving me the mentioned error:
$ docker build -t what/ever:latest [...] $ docker run --rm what/ever:latest /bin/sh: [./entrypoint.sh]: not found
I made sure that my
entrypoint.sh file actually existed by overriding the entrypoint and inspecting the container:
$ docker run -it --rm --entrypoint sh what/ever:latest /app # ls -l total 28 -rwxr-xr-x 1 root root 137 Nov 7 19:32 entrypoint.sh [...]
The file existed at the expected location, so what’s the issue?
It’s the quotes!
After verifying my Dockerfile again, I saw my – in retrospect – obvious mistake: the quotes!
ENTRYPOINT list is parsed as a JSON array, it needs to be in double-quotes, not single-quotes.
Dockerfile like follows fixes the issue:
# before ENTRYPOINT ['./entrypoint.sh'] # after ENTRYPOINT ["./entrypoint.sh"]
In case the
entrypoint.sh script would really be missing, the error would also be different than the one above. You would rather get something more descriptive like:
starting container process caused: exec: "./entrypoint.sh": stat ./entrypoint.sh: no such file or directory