Starting container process caused “exec: \”/bin/sh\”: stat /bin/sh: no such file or directory”: unknown

There are two things happening here.

A Dockerfile that starts FROM scratch starts from a base image that has absolutely nothing at all in it. It is totally empty. There is not a set of base tools or libraries or anything else, beyond a couple of device files Docker pushes in for you.

The ENTRYPOINT echo ... command gets rewritten by Docker into ENTRYPOINT ["/bin/sh", "-c", "echo ..."], and causes the CMD to be totally ignored. Unless overridden with docker run --entrypoint, this becomes the main process the container runs.

Since it is a FROM scratch image and contains absolutely nothing at all, it doesn’t contain a shell, hence the “/bin/sh: no such file or directory” error.

Leave a Comment