This error occurs when Docker cannot find or execute the entrypoint script specified in your Dockerfile or container configuration. Common causes include incorrect file paths, missing files in the image, Windows line endings (CRLF), volume mounts shadowing files, or permission issues.
When you see the `OCI runtime create failed: exec: "/docker-entrypoint.sh": stat /docker-entrypoint.sh: no such file or directory` error, Docker is unable to start your container because it cannot locate or execute the entrypoint script. The OCI (Open Container Initiative) runtime is the low-level component responsible for actually running containers, and it reports this error before the container even starts. This error can be misleading because the file might actually exist in your image, but Docker still cannot find it. The most common reasons include: 1. **Path mismatch**: The path specified in ENTRYPOINT does not match where the file was copied in the Dockerfile. 2. **Windows line endings**: If the script has CRLF line endings instead of LF, the shebang (`#!/bin/bash\r`) becomes invalid, causing Linux to report "no such file or directory" for the interpreter. 3. **Volume mounts**: A volume mount might be shadowing the directory where your entrypoint lives, effectively hiding it. 4. **Multi-stage build issues**: The file was not copied from a builder stage to the final image. Unlike permission denied errors, this error specifically indicates the file cannot be found at the specified path at container startup time.
First, check if the entrypoint file actually exists in your built image. Run the image with an alternative command to inspect its contents:
# Start a shell in the image (bypassing entrypoint)
docker run --rm -it --entrypoint /bin/sh your-image:tag
# Once inside, check if the file exists
ls -la /docker-entrypoint.sh
# Or check the expected directory
ls -la /app/If the file does not exist, the issue is in your Dockerfile - the file was never copied into the image.
Ensure your Dockerfile properly copies the entrypoint script. The COPY instruction should run before ENTRYPOINT:
# Correct - copy then set entrypoint
WORKDIR /app
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]Common mistakes:
# Wrong - file copied to wrong location
COPY docker-entrypoint.sh /app/
ENTRYPOINT ["/docker-entrypoint.sh"] # Looks in / not /app/
# Wrong - relative path without WORKDIR
COPY docker-entrypoint.sh .
ENTRYPOINT ["./docker-entrypoint.sh"] # Depends on WORKDIRUse absolute paths in ENTRYPOINT for clarity.
If the file exists but Docker still reports "no such file or directory", check for Windows line endings. This is especially common when developing on Windows:
# Check file type
file docker-entrypoint.sh
# If it shows "CRLF line terminators", that's the problem
# Check for carriage returns
cat -A docker-entrypoint.sh | head -5
# ^M at end of lines indicates Windows line endingsFix with dos2unix or sed:
# Using dos2unix
dos2unix docker-entrypoint.sh
# Using sed
sed -i 's/\r$//' docker-entrypoint.shOr fix in your Dockerfile:
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN sed -i 's/\r$//' /docker-entrypoint.sh && chmod +x /docker-entrypoint.shVolume mounts in Docker completely replace the target directory's contents. If you mount a volume over a directory containing your entrypoint, the entrypoint disappears:
# docker-compose.yml - problematic setup
services:
app:
build: .
volumes:
- ./src:/app # This shadows everything in /app including entrypoint!Solutions:
# Option 1: Put entrypoint outside mounted directory
services:
app:
build: .
volumes:
- ./src:/app/src # Mount to subdirectory instead
# Option 2: Place entrypoint in root, not /app
# In Dockerfile:
# COPY docker-entrypoint.sh /docker-entrypoint.sh
# ENTRYPOINT ["/docker-entrypoint.sh"]In multi-stage builds, files from builder stages are not automatically available in the final stage. You must explicitly COPY them:
# Builder stage
FROM node:18 AS builder
WORKDIR /app
COPY . .
RUN npm run build
# Final stage - MUST copy entrypoint from builder or source
FROM node:18-slim
WORKDIR /app
# Copy built assets
COPY --from=builder /app/dist ./dist
# Don't forget the entrypoint!
COPY --from=builder /app/docker-entrypoint.sh /docker-entrypoint.sh
# Or copy directly from build context:
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]Docker's ENTRYPOINT and CMD accept two forms. The exec form (JSON array) requires double quotes, not single quotes:
# Correct - double quotes (JSON syntax)
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["start"]
# Wrong - single quotes cause parse errors
ENTRYPOINT ['/docker-entrypoint.sh'] # Will fail!
# Alternative - shell form (works but has limitations)
ENTRYPOINT /docker-entrypoint.shThe exec form is preferred because it:
- Runs the script directly without a shell wrapper
- Allows proper signal handling (SIGTERM reaches your script)
- Passes arguments correctly from CMD
If your script's shebang references a shell that does not exist in the image, you will get this error. This is common with minimal images like Alpine:
# Script uses bash but Alpine only has sh by default
#!/bin/bash # Won't work on Alpine without installing bash
# Option 1: Use sh instead of bash in your script
#!/bin/sh
# Option 2: Install bash in Alpine
FROM alpine:3.18
RUN apk add --no-cache bash
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]Check what shells are available:
docker run --rm -it --entrypoint /bin/sh alpine:3.18 -c "cat /etc/shells"While permission issues usually show a different error, ensure your entrypoint has execute permissions:
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]Or set permissions before copying:
# On your host machine
chmod +x docker-entrypoint.sh
git update-index --chmod=+x docker-entrypoint.sh # Preserve in gitNote: Even with +x, if the file has CRLF line endings or the shell does not exist, you will still get 'no such file or directory'.
After making any changes to your Dockerfile or entrypoint script, rebuild the image without using cached layers:
# Rebuild without cache
docker build --no-cache -t your-image:tag .
# Or with docker-compose
docker-compose build --no-cache
# Then run to test
docker run --rm your-image:tagThe --no-cache flag ensures Docker does not reuse cached layers that might contain the old, broken file.
Understanding OCI Runtime Errors: The OCI (Open Container Initiative) runtime is the component that actually creates and runs containers. When you see "OCI runtime create failed", the error occurred before your container even started - during the setup phase when Docker tries to configure the container's initial process.
Debugging with inspect: You can examine your image's configuration to see what entrypoint is set:
docker inspect your-image:tag | jq '.[0].Config.Entrypoint'
docker inspect your-image:tag | jq '.[0].Config.Cmd'Docker history: See the layers in your image to verify COPY happened:
docker history your-image:tagEntry point vs CMD confusion: Remember that ENTRYPOINT defines the executable and CMD provides default arguments. If both are defined:
- ENTRYPOINT ["/entrypoint.sh"] and CMD ["start"] results in /entrypoint.sh start
- Override CMD at runtime: docker run myimage serve runs /entrypoint.sh serve
- Override ENTRYPOINT at runtime: docker run --entrypoint /bin/sh myimage
Git and line endings: Configure Git to prevent line ending issues:
# .gitattributes
*.sh text eol=lf
docker-entrypoint.sh text eol=lfCI/CD pipelines: When this error occurs only in CI but not locally, check if:
1. The CI uses a different OS (line endings)
2. The CI clones the repo with different git settings
3. Build context is different (missing files)
unable to configure the Docker daemon with file /etc/docker/daemon.json
How to fix 'unable to configure the Docker daemon with file daemon.json' in Docker
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker
cannot open '/etc/passwd': Permission denied
How to fix 'cannot open: Permission denied' in Docker