Skip to content

'docker-compose up' not working on Windows #990

Closed
@yankolo

Description

@yankolo

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) actions/checkout#135
(2) https://www.edwardthomson.com/blog/git_for_windows_line_endings.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions