How to Fix the standard_init_linux.go:190: exec user process caused “no such file or directory” Error in Docker

When building or running Docker containers, you may sometimes encounter the following frustrating error message:

standard_init_linux.go:190: exec user process caused "no such file or directory"

This error usually appears when Docker tries to start your container but fails to locate or execute the specified entrypoint or command.

In this blog, we’ll explore the common causes of this error and provide clear solutions to fix it.


✅ What Causes This Error?

At its core, the error occurs because Docker cannot find the file specified in the CMD or ENTRYPOINT of your Dockerfile, or because of an underlying environment mismatch.

Here are the most common causes:

  1. Incorrect File Path in CMD or ENTRYPOINT.
  2. The script specified as an entrypoint lacks execution permissions.
  3. Wrong Line Endings (Windows CRLF vs Unix LF).
  4. Specified interpreter (e.g., #!/bin/bash) is not available in the container.
  5. Using an incompatible base image (architecture mismatch).

✅ 1️⃣ Check File Paths in Dockerfile

Example Dockerfile mistake:

FROM alpine
COPY ./start.sh /start.sh
ENTRYPOINT ["/start.sh"]

If /start.sh is missing or in a different path, the error will occur.

✅ Fix:
Ensure the file is copied and the path is correct.

FROM alpine
COPY ./start.sh /usr/local/bin/start.sh
ENTRYPOINT ["/usr/local/bin/start.sh"]

✅ 2️⃣ Ensure Executable Permission

If your entrypoint is a script, it must have execution permission.

❌ Common mistake (causes the error):

COPY start.sh /start.sh
# start.sh lacks execution permission

✅ Fix:
Set executable permission explicitly in Dockerfile:

FROM alpine
COPY start.sh /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["/start.sh"]

Or set it locally before building:

chmod +x start.sh

✅ 3️⃣ Fix Line Endings (CRLF vs LF)

If the script was created on Windows, it may have CRLF line endings, which are not compatible in Linux-based containers.

Symptoms:
The error appears even if the file exists and is executable.

✅ Fix:
Convert line endings to Unix format using tools like dos2unix:

dos2unix start.sh

Or configure your editor (VSCode, etc.) to use LF endings.


✅ 4️⃣ Ensure Correct Interpreter Is Installed

If your script starts with a shebang like #!/bin/bash but the container only has /bin/sh, it fails.

❌ Example:

FROM alpine
COPY start.sh /start.sh
ENTRYPOINT ["/start.sh"]

Where start.sh has:

#!/bin/bash
echo "Starting app"

But Alpine doesn’t have bash by default.

✅ Fix:
Either change the shebang to #!/bin/sh, or install bash:

FROM alpine
RUN apk add --no-cache bash
COPY start.sh /start.sh
ENTRYPOINT ["/start.sh"]

✅ 5️⃣ Verify Architecture Compatibility

Ensure you’re not using a binary built for a different architecture (e.g., x86 vs ARM).

✅ Check your base image architecture:

docker inspect --format '{{.Os}}/{{.Architecture}}' alpine

Ensure any custom binaries match the architecture.


✅ Conclusion

The standard_init_linux.go:190: exec user process caused "no such file or directory" error is commonly caused by one of the following:

  • Incorrect file paths.
  • Missing execution permissions.
  • Wrong line endings.
  • Missing interpreters.
  • Architecture mismatch.

By carefully checking your Dockerfile, ensuring scripts have proper permissions, fixing line endings, and using the correct interpreters, you can resolve this error quickly and build reliable Docker images.

Sharing Is Caring:

Leave a Comment