exec no such file or directory 🐳 Docker

exec /docker-entrypoint.sh: no such file or directory (CRLF line endings / missing interpreter)

The entrypoint file exists, but the kernel can’t run it — almost always Windows CRLF line endings in the script, or a shebang pointing at a shell the image doesn’t have.

Seen on: Docker

Meaning

“No such file or directory” refers to the interpreter in the first line (#!/bin/bash\r), not the script. A script saved with CRLF asks for “/bin/bash\r”, which doesn’t exist. The same error appears for binaries compiled against glibc running on Alpine (musl).

Common causes

  • Script has Windows (CRLF) line endings — Git autocrlf on Windows
  • Shebang uses /bin/bash but the image only has sh
  • Binary built for glibc run on Alpine/musl
  • Wrong architecture binary

⚡ Quick fix

  1. Convert to LF: dos2unix or set .gitattributes
  2. Use #!/bin/sh or install bash
  3. Build the binary for the target libc/arch (CGO_ENABLED=0 for Go)

Detailed fix by platform

Dockerfile

  1. bash
    COPY docker-entrypoint.sh /usr/local/bin/
    RUN sed -i 's/\r$//' /usr/local/bin/docker-entrypoint.sh && chmod +x /usr/local/bin/docker-entrypoint.sh

Git

  1. bash
    # .gitattributes
    *.sh text eol=lf

How to diagnose

  1. Line endings — file docker-entrypoint.sh (look for CRLF)
  2. Shebang — head -1 of the script
  3. Binary — file ./app — static or dynamic, which arch?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.