Skip to content
ohsudo, Home
Docker & Containers

Docker "exec: executable file not found in $PATH": the command isn't in the image

Fix Docker "OCI runtime create failed … executable file not found in $PATH": use the image's shell, fix CMD and ENTRYPOINT exec form, and check PATH and scripts.

Beginner3 min readApplies to Docker Engine 24+ · Docker Desktop · Docker Compose v2 · Kubernetes

by OhSudo ·

Checked on real software: Docker 29 · November 2026How we check

Not sure this is your cause?Find it step by step: Container won't start →

Part of a learning path:Docker: from first container to production

$ docker run --rm alpine:3.21 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

Docker created the container, then couldn’t find the program to start in it. The part that matters is at the end: exec: "bash" is the name it looked for, and it isn’t in any folder of the container’s PATH. docker run exits with code 127, like a shell for a command it can’t find.

With docker exec, it reads like this:

OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH

TL;DR

Terminal window
# Small images have sh, not bash
docker run --rm -it alpine:3.21 sh
docker exec -it web sh
# CMD in exec form: one string per argument
CMD ["npm", "start"] # not ["npm start"]

1. The image doesn’t have it

Small images leave out what they don’t need. Alpine and BusyBox have sh, not bash. Slim and distroless images may have no shell at all, and no curl, ps or ping either:

Terminal window
docker run --rm alpine:3.21 sh -c 'echo hello from sh'

Use sh, or install the tool in your own image: RUN apk add --no-cache bash on Alpine, RUN apt-get update && apt-get install -y --no-install-recommends curl on Debian. For an image without a shell, debug from outside: docker cp, docker logs, or a debugging container that shares the network, such as docker run --rm -it --network container:web nicolaka/netshoot. Try the first case in the terminal.

2. CMD or ENTRYPOINT written as one string

In the JSON (“exec”) form, every word is a separate string. Written as one string, the whole line becomes the program’s name:

CMD ["npm start"] # looks for a program called "npm start"
exec: "npm start": executable file not found in $PATH

Split it:

CMD ["npm", "start"]

The shell form, CMD npm start, also works. It runs through /bin/sh -c, so it needs a shell in the image, and the signals Docker sends to stop the container reach the shell, not your program. The Dockerfile Generator writes CMD in exec form.

3. The program is there, outside PATH

If you copy a binary to /app/server, CMD ["server"] won’t find it, as /app isn’t in PATH. Use the full path, CMD ["/app/server"], or put it in /usr/local/bin/. To see the image’s PATH and its start command:

Terminal window
docker image inspect app:1.0 --format '{{.Config.Env}} {{.Config.Entrypoint}} {{.Config.Cmd}}'

In multi-stage builds, check that the COPY --from=build line copies the program into the final image, with the path you expect.

4. Neighbouring errors with a script

A script with the right name can still fail to start, with other messages:

  • exec: "/app/start.sh": permission denied (exit code 126): the file isn’t executable. Add RUN chmod +x /app/start.sh, or COPY --chmod=755 start.sh /app/.
  • exec /app/start.sh: no such file or directory, although the file exists: its first line, the shebang, names an interpreter the image doesn’t have (#!/bin/bash on Alpine), or the file has Windows line endings, so the interpreter’s name ends in an invisible \r. Use #!/bin/sh, and convert it with dos2unix or sed -i 's/\r$//' start.sh.

In Kubernetes, the same problem shows up as StartError or RunContainerError, and the pod ends in CrashLoopBackOff. kubectl describe pod shows the same exec: … executable file not found message in its events.

Shell, we have a problem!

Similar, but different: exec format error means the program was found, built for another CPU. Exit code 137 means it started, and was killed. pull access denied means the image itself couldn’t be downloaded. For everyday commands, see the Docker CLI cheat sheet.

$ ./practice.sh

Practice this in the terminal

Open the Terminal Playground with this article’s scenario loaded. It is safe and runs in your browser.

Open the terminal →

Found this useful? Share it.

Found a mistake? Let us know at contact@ohsudo.com.

Tools

Try it yourself

Articles

Related articles