fix: docker container fails to start due to CRLF line endings in start.sh #840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Description
The YOLO ML backend Docker container was failing to start with the error:
This error occurs when the
start.shshell script contains Windows-style line endings (CRLF -\r\n) instead of Unix-style line endings (LF -\n). When Docker tries to execute the script, the shell interpreter cannot find the correct interpreter path because it's looking for/bin/bash\rinstead of/bin/bash.Root Cause
start.shfile was created or edited on Windows, which uses CRLF (\r\n) line endingscore.autocrlfsettings\n) line endings for shell scripts\rcharacter causes the shebang line to failImpact
Solution
Added line ending normalization and permission setting in the Dockerfile to ensure the script works regardless of the development environment.
Changes Made
Modified:
DockerfileWhy This Fix Works
sed -i 's/\r$//'removes carriage return characters from line endingschmod +xensures the script has execute permissions.gitattributesprevents Git from converting line endings in the futureTesting
Tested on:
docker-compose up --buildAdditional Notes
This is a common issue when developing cross-platform Docker containers. The fix ensures compatibility across Windows, macOS, and Linux development environments without requiring users to manually fix line endings.
Alternative Solutions Considered
dos2unixlocally - adds dependency and manual stepENTRYPOINTwith shell form - doesn't solve the root causeChecklist