Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Docker: OCI runtime create failed: exec: no such file or directory

The entrypoint points at a path missing from the final image. Check WORKDIR, multi-stage copies, line endings and the base image shell.

~5 min readDocker
#docker#entrypoint#runc#containers
Bold white headline reading EXEC NOT FOUND beside a cyan container crate with an amber missing file slot.

Introduction & Quick Summary

A container that built without errors refuses to start:

code
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: exec: "/app/start.sh": stat /app/start.sh: no such file or directory: unknown.

Quick answer: the runtime resolved the entrypoint to a path that does not exist inside the final image, or the kernel could not execute the file at that path. The image built fine because the path is only checked when the container starts.

bash
docker create --name probe my-app:latest docker cp probe:/app ./check && ls -l ./check docker inspect my-app:latest --format '{{json .Config.Entrypoint}} {{json .Config.Cmd}} {{.Config.WorkingDir}}'

The message names the exact path, which narrows the cause quickly: a missing file in a multi-stage build, a wrong WORKDIR, a script copied to a different directory, a Windows line ending in the shebang, or a base image that has no shell at all. This guide covers how the entrypoint is resolved, the six cases that produce this error, and how to inspect an image without starting it.

Core Mechanics, Signatures & Reproducible Setup

ENTRYPOINT and CMD combine into one executable plus arguments. The kernel then tries to execute that path inside the container's filesystem and mounts.

dockerfile
FROM node:22-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev COPY . . ENTRYPOINT ["node", "server.js"]
bash
docker build -t my-app . && docker run --rm my-app

Reproduce the failure by pointing at a file that was never copied:

dockerfile
FROM node:22-alpine WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev ENTRYPOINT ["/app/start.sh"]
bash
docker build -t broken . && docker run --rm broken # exec: "/app/start.sh": stat /app/start.sh: no such file or directory
What the runtime receivesResolutionTypical result
["node", "server.js"]PATH lookup for node, relative file from WORKDIRworks if both exist
["/app/start.sh"]absolute path, must exist and be executablethis error if absent
["sh", "-c", "..."]shell from the imagefails on distroless, no sh
[] with CMD onlyCMD used as entrypointerror names the CMD path
shell form ENTRYPOINT node server.jswrapped as sh -cdifferent error if no shell

The exit code alone does not say which of these happened; the path in the message does. Note also that stat ... no such file or directory can mean the file exists but its interpreter does not, for example #!/bin/bash in an Alpine image that only ships sh.

CauseMessage detailFix
File never copiedpath under WORKDIR is absentcopy it in the final stage
Wrong WORKDIRrelative path resolves to another directoryset WORKDIR before COPY, use absolute entrypoint
Shell removedsh or bash not foundexec form with the real binary, or add a shell
CRLF shebangno such file or directory or exec format errorconvert to LF, add .gitattributes
Missing interpreter#!/usr/bin/env python3 in a slim imageinstall the interpreter or use the full base image
Wrong architectureexec format error on a different platformbuild for the target platform

Key Comparison Table

FormWritten asRunsNotes
exec formENTRYPOINT ["/app/start.sh"]directly, no shellno variable expansion
shell formENTRYPOINT /app/start.shsh -c wrapperneeds a shell in the image
CMD as argsENTRYPOINT ["node"] plus CMD ["server.js"]node server.jsCMD is overridable
Compose commandcommand: ["npm", "start"]replaces CMDentrypoint still applies
Compose entrypointentrypoint: ["/bin/sh", "-c"]replaces ENTRYPOINTcommand becomes arguments
InvestigationCommandTells you
Config without runningdocker inspect IMAGE --format '{{json .Config}}'entrypoint, cmd, workdir, env
File listingdocker create --name p IMAGE then docker cp p:/app ./xwhat the final layer contains
Override entrypointdocker run --rm --entrypoint sh IMAGE -c 'ls -l /app'needs a shell in the image
Historydocker history IMAGEwhich layer added or removed the file
Build contextdocker build --no-cache -t t .stale cache hiding a deleted COPY
Compose resolutiondocker compose configmerged entrypoint, command, workdir

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Multi-stage builds that forget to copy

dockerfile
FROM node:22 AS build WORKDIR /app COPY . . RUN npm ci && npm run build FROM node:22-alpine WORKDIR /app COPY --from=build /app/dist ./dist COPY --from=build /app/package*.json ./ ENTRYPOINT ["node", "dist/server.js"]

The classic failure is building into dist in the first stage and copying /app/build, or copying the source but not the compiled output. docker run --rm --entrypoint ls IMAGE -l /app on an image with a shell shows the gap immediately.

2. Windows line endings in scripts

bash
file start.sh # start.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators

A shebang line #!/bin/sh\r asks the kernel for an interpreter named /bin/sh\r, which does not exist. The error then reads no such file or directory even though the script is present.

bash
sed -i 's/\r$//' start.sh
gitattributes
*.sh text eol=lf

Commit the attribute file so editors on Windows do not reintroduce the problem, and add RUN chmod +x /app/start.sh because COPY does not always preserve the executable bit from the build context.

3. Distroless and scratch images

dockerfile
FROM gcr.io/distroless/nodejs22-debian12 COPY --from=build /app /app WORKDIR /app ENTRYPOINT ["server.js"]

Distroless images set their own entrypoint (/nodejs/bin/node) and contain no shell, no ls, no sh. Pointing the entrypoint at a shell script fails both because the script may be missing and because the interpreter is missing. For Go binaries, scratch has no CA certificates either, so HTTPS calls fail later with a TLS error that looks unrelated.

4. ENTRYPOINT plus CMD composition

dockerfile
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] CMD ["postgres"]

The final command is the entrypoint plus the CMD arguments. Overriding CMD in Compose keeps the entrypoint, so command: ["sh", "-c", "sleep infinity"] still runs the entrypoint script first. Use the docker-compose editor to check the merged configuration and the YAML formatter when a compose file fails to parse.

5. Inspecting without starting

bash
docker create --name p my-app:latest docker export p | tar -tvf - | grep -E 'app/(start.sh|server.js)' docker rm p

docker export works on images without a shell, which makes it the reliable way to confirm whether the file exists. docker inspect gives the configured path, and docker history shows the layer that should have added it.

6. exec into a running container fails the same way

bash
docker exec -it api /bin/bash # OCI runtime exec failed: exec failed: unable to start container process: # exec: "/bin/bash": stat /bin/bash: no such file or directory

The container is healthy but the binary is absent. Use /bin/sh, or run a debug container with the same image and the right tools: docker run --rm -it --entrypoint sh my-app. On Kubernetes, kubectl debug with an ephemeral container avoids changing the production image.

Common Compilation/Runtime Mistakes & Version Gotchas

  • Assuming a successful build proves the path exists. COPY of a missing file fails, but a RUN that deletes the file, a .dockerignore that excludes it, or a WORKDIR mismatch all build cleanly.
  • Relative entrypoints without a WORKDIR. ENTRYPOINT ["node", "server.js"] resolves server.js against the working directory, which defaults to /. Either set WORKDIR explicitly or use an absolute path.
  • Shell-form entrypoints in minimal images. Shell form needs /bin/sh -c; distroless images do not have it.
  • Stale build cache. COPY . . followed by a deleted file keeps the old layer when the cache is reused. --no-cache confirms it.
  • Architecture mismatch. exec format error on Apple Silicon building linux/amd64 by accident, or the reverse; use --platform and docker buildx.
  • Docker 25 and the containerd image store. Error wording changed from runc create failed to failed to create task for container on some daemons, but the path in the message is still the answer.
  • Kubernetes command and args. They override the image's ENTRYPOINT and CMD respectively; setting command to a script path that is not in the image reproduces this error at pod start.
  • Read-only root filesystems. A script that writes a lock file next to itself fails at start with a permission error rather than this one, but both are startup-time path problems worth checking together.

Treat the entrypoint as an API between the image and the orchestrator: absolute paths, exec form, a file that exists in the final stage, LF endings and an interpreter that ships in the base image. That combination eliminates nearly every case of this error.

Official documentation: the Dockerfile reference and docker container run.

Official references

primary documentation

The Docker documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Docker work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Docker guides

More in Docker

All Docker guides

The guides filed next to this one in Docker, in library order.