docker run fails because the executable is not found in the container
docker: Error response from daemon: failed to create task for container: ... exec: "<name>": executable file not found in $PATHShort answer
Docker looked for the program you named inside the container image and did not find it. Either the image does not contain that program, or you gave a shell line such as cd app && node x.js to something that runs without a shell. Check what the image has with --entrypoint sh, then fix the command.
Fix it fast
1Find out which cause you have
Open a shell in the image, bypassing its entrypoint, and look for the program yourself.
docker run --rm -it --entrypoint sh <image> # inside: command -v <program>2Match what you see, then jump to its fix
- 1
command -v prints nothing for the programThe program is not installed in the imageFix - 2
The name in the error contains spaces or && , such as "cd app && node server.js"A whole command line was passed as one program nameFix - 3
The program named in the error is something you typed after the image name, such as bashAn argument after the image name replaced the command, or the entrypointFix
- 1
What does the error look like?
docker: Error response from daemon: failed to create task for container: ... exec: "<name>": executable file not found in $PATHOCI runtime create failed: ... executable file not found in $PATH: unknown
Cause 1 of 3
The program is not installed in the image
1Check
A slim or minimal image may not include what runs fine on your machine. The program also may exist under a path outside PATH.
echo $PATH
ls /usr/local/bin /usr/bin | head2Fix
Install it in the Dockerfile, use a base image that includes it, or call it by its full path.
RUN apt-get update && apt-get install -y --no-install-recommends <package> && rm -rf /var/lib/apt/lists/*3Verify
Run the program in a new container.
docker run --rm <image> <program> --versionConfirmed by docs.docker.com
Cause 2 of 3
A whole command line was passed as one program name
1Check
Exec form does not start a shell. A JSON array with one string is read as one executable name, not a command line.
grep -n "CMD\|ENTRYPOINT" Dockerfile2Fix
Split the words into array items, or call a shell on purpose with sh -c. Prefer WORKDIR over cd.
WORKDIR /app
CMD ["node", "server.js"]3Verify
The container starts and stays up.
docker build -t myapp .
docker run --rm myappConfirmed by docs.docker.com
Cause 3 of 3
An argument after the image name replaced the command, or the entrypoint
1Check
Arguments after the image are appended to an exec-form ENTRYPOINT, or replace CMD. The --entrypoint flag overrides the image's entrypoint and clears its default CMD.
docker image inspect --format '{{json .Config.Entrypoint}} {{json .Config.Cmd}}' <image>2Fix
Run your command through the entrypoint override when you want a different program.
docker run --rm -it --entrypoint bash <image>3Verify
The shell opens, or the program prints its output.
docker run --rm --entrypoint sh <image> -c 'echo ok'Confirmed by docs.docker.com
How do I stop it coming back?
- Use exec form with one word per array item, and WORKDIR instead of cd.
- Test a new image with --entrypoint sh before wiring it into compose.
- Use a multi-stage build and copy the final binary with its full path into the runtime stage.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix