Dockerfile Entrypoint: “file not found”
I was working with a fairly simple Dockerfile, defining an entrypoint and always got a “not found” error when trying to run the container.
My 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!
Since the ENTRYPOINT
list is parsed as a JSON array, it needs to be in double-quotes, not single-quotes.
Adjusting the 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
Like to comment? Feel free to send me an email or reach out on Twitter.
Did this or another article help you? If you like and can afford it, you can buy me a coffee (3 EUR) ☕️ to support me in writing more posts. In case you would like to contribute more or I helped you directly via email or coding/troubleshooting session, you can opt to give a higher amount through the following links or adjust the quantity: 50 EUR, 100 EUR, 500 EUR. All links redirect to Stripe.