Starting container process caused exec… stat /bin/bash no such file or directory

What is causing this docker error?

Let us simulate this error message by running an alpine docker container:

[[email protected] ~]# docker run -it alpine /bin/bash
Unable to find image 'alpine:latest' locally
Trying to pull repository docker.io/library/alpine ...
latest: Pulling from docker.io/library/alpine
89d9c30c1d48: Pull complete
Digest: sha256:c19173c5ada610a5989151111163d28a67368362762534d8a8121ce95cf2bd5a
Status: Downloaded newer image for docker.io/alpine:latest
/usr/bin/docker-current: Error response from daemon:
 oci runtime error: container_linux.go:235:
 starting container process caused "exec: "/bin/bash":
 stat /bin/bash: no such file or directory".

Reason for this error

Look at the last line, it says:

"exec: \"/bin/bash\": stat /bin/bash: no such file or directory".

The alpine image does not come with bash. It has the sh shell.

Solution

Let us try again calling /bin/sh.

docker run -it alpine /bin/sh

And, it works!

[[email protected] ~]#  docker run -it alpine /bin/sh
/ #
Starting container process caused exec