Dockerfile Entrypoint: “file not found”

1 minute read

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


COPY . /app

RUN ["chmod", "+x", "./"]

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: [./]: not found

I made sure that my 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

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

# after

In case the 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: "./": stat ./ no such file or directory

Like to comment? Feel free to send me an email or reach out on Twitter.