Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Docker - Fixing Windows Line Endings In BASH Scripts When Using Volumes

If you use Docker on Windows, and mount your application's code through a volume, you may find that you can't run your code's BASH scripts, and configuration files. This is because when the code was checked out through git, it placed the OS's native line endings on the files.


Add a .gitattributes file to the top of your repository with the following contents.

* text=auto
*.sh text eol=lf
*.conf text eol=lf

Now commit that and go re-check-out your codebase before trying again.


Last updated: 8th August 2020
First published: 2nd June 2020