Skip to content
Latchkey

Docker "exec user process caused: no such file or directory"

The container’s init tried to exec the entrypoint and the kernel reported the target (or its interpreter) does not exist. Usually the file is there but its shebang interpreter or shared libraries are not.

What this error means

The container exits at startup with standard_init_linux.go:...: exec user process caused: "no such file or directory", even though the entrypoint file appears present in the image.

docker run output
standard_init_linux.go:228: exec user process caused: no such file or directory
# entrypoint exists, but its #! interpreter (or a needed .so) does not

Diagnose it: read the container, not the compose file

A container that exits immediately in CI has almost always logged the reason and then been cleaned up. Capture the logs and the exit code before changing configuration.

Terminal
# why did it stop?
docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Image}}'
docker logs <container> 2>&1 | tail -50
docker inspect <container> --format '{{.State.ExitCode}} {{.State.OOMKilled}} {{.State.Error}}'

Common causes

CRLF line endings in the entrypoint script

A #!/bin/sh\r shebang (Windows CRLF) makes the kernel look for an interpreter literally named /bin/sh\r, which does not exist - reported as "no such file or directory".

Shebang interpreter not in the image

A script with #!/bin/bash in an Alpine image (which ships ash, not bash) fails because the interpreter path is absent.

A dynamically-linked binary missing its loader

A glibc-linked binary copied into a musl (Alpine) image cannot find its dynamic loader, producing the same "no such file or directory" at exec time.

How to fix it

Fix line endings and the shebang

Normalize the script to LF and point the shebang at an interpreter that exists in the image.

Dockerfile
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
# use #!/bin/sh on Alpine; install bash if you need it
RUN apk add --no-cache bash

Match the binary’s libc to the base image

  1. Build static binaries, or build against musl when targeting Alpine.
  2. Use a glibc base (debian/ubuntu slim) for glibc-linked binaries.
  3. Verify with ldd <binary> that all shared libraries resolve in the image.

How to prevent it

  • Enforce LF endings on scripts via .gitattributes.
  • Match the binary’s libc and interpreter to the base image.
  • Smoke-test the image with docker run --rm <image> in CI before publishing.

Frequently asked questions

What causes Docker "exec user process caused: no such file or directory"?
There are 3 common causes: crlf line endings in the entrypoint script, shebang interpreter not in the image, and a dynamically-linked binary missing its loader. A #!/bin/sh\r shebang (Windows CRLF) makes the kernel look for an interpreter literally named /bin/sh\r, which does not exist - reported as "no such file or directory".
How do I fix Docker "exec user process caused: no such file or directory"?
There are 2 fixes depending on which cause you have: fix line endings and the shebang and match the binary’s libc to the base image. Work through them in order, since the first is the most common.
What does Docker "exec user process caused: no such file or directory" actually mean?
The container exits at startup with standard_init_linux.go:...: exec user process caused: "no such file or directory", even though the entrypoint file appears present in the image.
How do I stop Docker "exec user process caused: no such file or directory" happening again?
Enforce LF endings on scripts via .gitattributes. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card