'docker-compose up' not working on Windows
When running docker-compose up, I receive the following error:
C:\docs\djangoproject.com> docker-compose up
Starting djangoprojectcom_db_1 ... done
Recreating djangoprojectcom_web_1 ... done
Attaching to djangoprojectcom_db_1, djangoprojectcom_web_1
db_1 | 2020-05-04 14:13:08.035 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-05-04 14:13:08.035 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-05-04 14:13:08.044 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-05-04 14:13:08.088 UTC [19] LOG: database system was shut down at 2020-05-04 14:11:35 UTC
db_1 | 2020-05-04 14:13:08.097 UTC [1] LOG: database system is ready to accept connections
web_1 | standard_init_linux.go:211: exec user process caused "no such file or directory"
djangoprojectcom_web_1 exited with code 1
After further examination, I have discovered that this happens because of the CRLF line endings on Windows. Basically, the core.autocrlf=true Git setting (which is preselected by default on the Windows Git installer) changes LF line endings to CRLF line endings on check out. Those CRLF line endings prevent the proper execution of .sh scripts. In this case, the docker-entrypoint.sh script, which runs automatically when executing the docker-compose up command, cannot be executed.
Since most Windows users will encounter the same issue (many do not change the default setting preselected in the installer), it will probably be good to add a .gitattributes file to explicitly instruct Git to keep the original LF line endings of .sh scripts.
Perhaps, it is possible to add a .gitattributes file similar to the one that GitHub recommends: https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings
Here are some additional resources concerning this problem: (1) https://github.com/actions/checkout/issues/135 (2) https://www.edwardthomson.com/blog/git_for_windows_line_endings.html
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stalebot, please don't close.
can you assigne this to me i will love to work on it sir
can you try this '*.sh text eol=lf'. This tells git to treat all .sh files as text files and to use LF line endings when checking out and committing changes. You can create this file in the root directory of your git repository, commit it, and then push the changes to the remote repository. This should resolve the issue you're facing with the docker-entrypoint.sh script not being executable on windows due to CRLF line endings.