# exec /entrypoint.sh: exec format error: /usr/bin/env: 'bash\r': No such file or directory

- **ID:** `docker/entrypoint-script-dos-line-endings`
- **Domain:** docker
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

The entrypoint script has Windows-style CRLF line endings (\r\n) instead of Unix-style LF (\n), causing the shebang interpreter to fail when it tries to execute 'bash\r' (with a carriage return character).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Docker 20.10.22 | active | — | — |
| Docker 24.0.4 | active | — | — |
| Docker 25.0.0 | active | — | — |

## Workarounds

1. **Convert the entrypoint script to Unix line endings using 'dos2unix' on the host: 'dos2unix entrypoint.sh' before building the image, or use 'sed -i 's/\r$//' entrypoint.sh'.** (95% success)
   ```
   Convert the entrypoint script to Unix line endings using 'dos2unix' on the host: 'dos2unix entrypoint.sh' before building the image, or use 'sed -i 's/\r$//' entrypoint.sh'.
   ```
2. **In the Dockerfile, add a RUN command to fix line endings after COPY: 'RUN sed -i 's/\r$//' /entrypoint.sh'.** (90% success)
   ```
   In the Dockerfile, add a RUN command to fix line endings after COPY: 'RUN sed -i 's/\r$//' /entrypoint.sh'.
   ```
3. **Configure Git to automatically convert line endings on checkout by setting 'git config core.autocrlf input' on the host, then re-clone or checkout the repository.** (85% success)
   ```
   Configure Git to automatically convert line endings on checkout by setting 'git config core.autocrlf input' on the host, then re-clone or checkout the repository.
   ```

## Dead Ends

- **** — The issue is not the shell type but the carriage return character in the shebang line; changing the shebang does not remove the \r character. (90% fail)
- **** — The base image does not affect the line endings of the script; the problem is in the script file itself, which is copied from the host. (95% fail)
- **** — The container fails to start due to the entrypoint error, so 'docker exec' cannot be used because the container is not running. (100% fail)
