exec: "bash": executable file not found in $PATH — the container was told to run a program that its image does not contain. Small images such as alpine have no bash; use sh, and spell every command the way the image knows it.

The same line appears when a whole command travels as one word, as in docker run alpine "echo hello" or ENTRYPOINT ["echo Hello"]: split the program from its arguments, or hand the string to sh -c. Docker 29.9.2 ended the message at $PATH, so search for that part.

The error

PS> docker run --rm alpine bash
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "bash": executable file not found in $PATH

Run 'docker run --help' for more information

The same request against a running container, through docker exec:

PS> docker exec fix7-exec bash
OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH

Why it happens

The words after the image name are not a shell command line. Docker passes them to the runtime, runc, which takes the first word as a program name and searches the container's own PATH for it. Nothing on your PC takes part, so having bash on Windows or in WSL changes nothing. alpine ships BusyBox, where /bin/sh and /bin/echo are links to /bin/busybox, and no bash. Both commands exited with code 127.

Quotes cause the other common case. docker run --rm alpine "echo hello" failed with exec: "echo hello", because the quotes made one program name with a space in it. A Dockerfile does the same with an exec-form array that holds one string: ENTRYPOINT ["echo Hello from fix7"] built without complaint and failed only at docker run, with exec: "echo Hello from fix7".

A missing absolute path reads differently: docker run --rm alpine /app/start.sh gave stat /app/start.sh: no such file or directory. That means the file is not in the image. A script that is there but saved with Windows line endings gives a third message, covered in the entrypoint CRLF post.

The fix

PS> docker run --rm alpine which sh
/bin/sh
PS> docker exec fix7-exec sh -c "echo inside; cat /etc/alpine-release"
inside
3.24.2

Ask the image what it has with which, then use that name. For an interactive shell add -it (docker exec -it <container> sh); the test ran without it because its shell had no terminal. In a Dockerfile, give each word its own array item:

FROM alpine:latest
ENTRYPOINT ["echo", "Hello from fix7"]
PS> docker run --rm fix7-exec-good
Hello from fix7

To look inside an image whose entrypoint is broken, override it for one run: docker run --rm --entrypoint sh fix7-exec-bad -c "echo override works" printed override works, so you can explore the file system and find the right path.

How it was reproduced

Docker Desktop 4.96.3 with engine 29.9.2, containerd v2.4.2 and runc 1.5.2, from Windows PowerShell 5.1, with the cached alpine:latest image (Alpine 3.24.2). Each command ran through cmd /c with 2>&1 so the error text was captured as printed. The container fix7-exec and the images fix7-exec-bad and fix7-exec-good are the test's own and were removed afterwards.

Frequently asked

Why does docker exec bash say executable file not found in $PATH?
The image has no bash. Alpine and other minimal images ship sh instead. Run docker exec -it with sh in place of bash, after checking with which sh that it exists.
What does exec: "echo hello": executable file not found mean?
The whole command reached Docker as one word, so it searched for a program whose name contains a space. Pass the program and its arguments as separate words, or as separate items in an exec-form ENTRYPOINT or CMD array.
What is the difference between executable file not found and no such file or directory?
Executable file not found means a bare name was searched in the container's PATH and not found. No such file or directory came back for an absolute path that does not exist in the image; a script with Windows line endings can produce it too.

More decoded errors in the Fixes category. Running, entering and removing containers step by step: Containers: run, look inside, stop, remove.